diff options
author | Robert Speicher <rspeicher@gmail.com> | 2016-03-29 01:03:29 +0300 |
---|---|---|
committer | Robert Speicher <rspeicher@gmail.com> | 2016-03-29 01:03:29 +0300 |
commit | 47a539dfd7733968b25b73e6b8b61348926207af (patch) | |
tree | c84a4cd61430ec48426098364f7260892f6b3024 /db/migrate/20130218141344_convert_closed_to_state_in_milestone.rb | |
parent | d73e1288595ef673b2d9c3024d7fe3909dac7184 (diff) |
Use raw SQL instead of Rails models in migrations where appropriate
Closes #14694.
Diffstat (limited to 'db/migrate/20130218141344_convert_closed_to_state_in_milestone.rb')
-rw-r--r-- | db/migrate/20130218141344_convert_closed_to_state_in_milestone.rb | 18 |
1 files changed, 11 insertions, 7 deletions
diff --git a/db/migrate/20130218141344_convert_closed_to_state_in_milestone.rb b/db/migrate/20130218141344_convert_closed_to_state_in_milestone.rb index 1978ea89153..d1174bc3d98 100644 --- a/db/migrate/20130218141344_convert_closed_to_state_in_milestone.rb +++ b/db/migrate/20130218141344_convert_closed_to_state_in_milestone.rb @@ -1,14 +1,18 @@ class ConvertClosedToStateInMilestone < ActiveRecord::Migration + include Gitlab::Database + def up - Milestone.transaction do - Milestone.where(closed: true).update_all(state: :closed) - Milestone.where(closed: false).update_all(state: :active) - end + execute "UPDATE #{table_name} SET state = 'closed' WHERE closed = #{true_value}" + execute "UPDATE #{table_name} SET state = 'active' WHERE closed = #{false_value}" end def down - Milestone.transaction do - Milestone.where(state: :closed).update_all(closed: true) - end + execute "UPDATE #{table_name} SET closed = #{true_value} WHERE state = 'cloesd'" + end + + private + + def table_name + Milestone.table_name end end |