Commit 60fdc04d authored by Dmitriy Zaporozhets's avatar Dmitriy Zaporozhets

Merge pull request #3098 from Undev/important-migrations-fix

IMPORTANT! Data converting in migrations was wrong. Fixed
parents b2a69262 4a55c698
class ConvertClosedToStateInIssue < ActiveRecord::Migration class ConvertClosedToStateInIssue < ActiveRecord::Migration
def up def up
Issue.transaction do Issue.transaction do
Issue.where(closed: true).update_all("state = 'closed'") Issue.where(closed: true).update_all(state: :closed)
Issue.where(closed: false).update_all("state = 'opened'") Issue.where(closed: false).update_all(state: :opened)
end end
end end
def down def down
Issue.transaction do Issue.transaction do
Issue.where(state: :closed).update_all("closed = 1") Issue.where(state: :closed).update_all(closed: true)
end end
end end
end end
class ConvertClosedToStateInMergeRequest < ActiveRecord::Migration class ConvertClosedToStateInMergeRequest < ActiveRecord::Migration
def up def up
MergeRequest.transaction do MergeRequest.transaction do
MergeRequest.where(closed: true, merged: true).update_all("state = 'merged'") MergeRequest.where(closed: true, merged: true).update_all(state: :merged)
MergeRequest.where(closed: true, merged: true).update_all("state = 'closed'") MergeRequest.where(closed: true, merged: false).update_all(state: :closed)
MergeRequest.where(closed: false).update_all("state = 'opened'") MergeRequest.where(closed: false).update_all(state: :opened)
end end
end end
......
class ConvertClosedToStateInMilestone < ActiveRecord::Migration class ConvertClosedToStateInMilestone < ActiveRecord::Migration
def up def up
Milestone.transaction do Milestone.transaction do
Milestone.where(closed: false).update_all("state = 'opened'") Milestone.where(closed: true).update_all(state: :closed)
Milestone.where(closed: false).update_all("state = 'active'") Milestone.where(closed: false).update_all(state: :active)
end end
end end
def down def down
Milestone.transaction do Milestone.transaction do
Milestone.where(state: :closed).update_all("closed = 1") Milestone.where(state: :closed).update_all(closed: true)
end end
end end
end end
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment