Commit d6fcc60d authored by Andreas Brandl's avatar Andreas Brandl

Use rollback helpers for pk migration

parent 52921fb3
......@@ -12,11 +12,6 @@ class InitializeConversionOfCiBuildsToBigint < ActiveRecord::Migration[6.0]
end
def down
trigger_name = rename_trigger_name(TABLE, COLUMNS, TARGET_COLUMNS)
remove_rename_triggers_for_postgresql TABLE, trigger_name
TARGET_COLUMNS.each do |column|
remove_column TABLE, column
end
revert_initialize_conversion_of_integer_to_bigint(TABLE, COLUMNS)
end
end
......@@ -5,20 +5,19 @@ class BackfillCiBuildsForBigintConversion < ActiveRecord::Migration[6.0]
DOWNTIME = false
TABLE = :ci_builds
COLUMNS = %i(id stage_id).freeze
def up
return unless should_run?
backfill_conversion_of_integer_to_bigint :ci_builds, %i(id stage_id), batch_size: 15000, sub_batch_size: 100
backfill_conversion_of_integer_to_bigint TABLE, COLUMNS, batch_size: 15000, sub_batch_size: 100
end
def down
return unless should_run?
Gitlab::Database::BackgroundMigration::BatchedMigration
.where(job_class_name: 'CopyColumnUsingBackgroundMigrationJob')
.where(table_name: 'ci_builds', column_name: 'id')
.where('job_arguments = ?', [%w[id stage_id], %w[id_convert_to_bigint stage_id_convert_to_bigint]].to_json)
.delete_all
revert_backfill_conversion_of_integer_to_bigint TABLE, COLUMNS
end
private
......
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