Merge branch 'better-issues-closed-at-cleanup' into 'master'
Handle EE edge cases in issues.closed_at migration Closes gitlab-ee#4803 See merge request gitlab-org/gitlab-ce!16926
This commit is contained in:
commit
4900390711
|
@ -18,12 +18,21 @@ class MigrateRemainingIssuesClosedAt < ActiveRecord::Migration
|
||||||
Gitlab::BackgroundMigration.steal('CopyColumn')
|
Gitlab::BackgroundMigration.steal('CopyColumn')
|
||||||
Gitlab::BackgroundMigration.steal('CleanupConcurrentTypeChange')
|
Gitlab::BackgroundMigration.steal('CleanupConcurrentTypeChange')
|
||||||
|
|
||||||
# It's possible the cleanup job was killed which means we need to manually
|
if migrate_column_type?
|
||||||
# migrate any remaining rows.
|
if closed_at_for_type_change_exists?
|
||||||
migrate_remaining_rows if migrate_column_type?
|
migrate_remaining_rows
|
||||||
|
else
|
||||||
|
# Due to some EE merge problems some environments may not have the
|
||||||
|
# "closed_at_for_type_change" column. If this is the case we have no
|
||||||
|
# other option than to migrate the data _right now_.
|
||||||
|
change_column_type_concurrently(:issues, :closed_at, :datetime_with_timezone)
|
||||||
|
cleanup_concurrent_column_type_change(:issues, :closed_at)
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def down
|
def down
|
||||||
|
# Previous migrations already revert the changes made here.
|
||||||
end
|
end
|
||||||
|
|
||||||
def migrate_remaining_rows
|
def migrate_remaining_rows
|
||||||
|
@ -39,4 +48,8 @@ class MigrateRemainingIssuesClosedAt < ActiveRecord::Migration
|
||||||
# migration, thus we don't need to migrate those environments again.
|
# migration, thus we don't need to migrate those environments again.
|
||||||
column_for('issues', 'closed_at').type == :datetime # rubocop:disable Migration/Datetime
|
column_for('issues', 'closed_at').type == :datetime # rubocop:disable Migration/Datetime
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def closed_at_for_type_change_exists?
|
||||||
|
columns('issues').any? { |col| col.name == 'closed_at_for_type_change' }
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue