Commit 5abc37bd authored by Andreas Brandl's avatar Andreas Brandl

Merge branch 'make-epics-position-migration-robust' into 'master'

Make epic_issues relative_position migration more robust

Closes #66923

See merge request gitlab-org/gitlab-ce!32646
parents b5343bba d1c761b3
......@@ -3,8 +3,23 @@
class RemoveEpicIssuesDefaultRelativePosition < ActiveRecord::Migration[5.2]
DOWNTIME = false
def change
include Gitlab::Database::MigrationHelpers
disable_ddl_transaction!
def up
# The column won't exist if someone installed EE, downgraded to CE
# before it was added in EE, then tries to upgrade CE.
if column_exists?(:epic_issues, :relative_position)
change_column_null :epic_issues, :relative_position, true
change_column_default :epic_issues, :relative_position, from: 1073741823, to: nil
else
add_column_with_default(:epic_issues, :relative_position, :integer, default: nil, allow_null: true)
end
end
def down
change_column_default :epic_issues, :relative_position, from: nil, to: 1073741823
change_column_null :epic_issues, :relative_position, false
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