2021-03-31 00:09:32 +00:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
class BackfillPushEventPayloadEventIdForBigintConversion < ActiveRecord::Migration[6.0]
|
2022-05-19 12:08:42 +00:00
|
|
|
disable_ddl_transaction!
|
|
|
|
|
2021-03-31 00:09:32 +00:00
|
|
|
include Gitlab::Database::MigrationHelpers
|
|
|
|
|
|
|
|
DOWNTIME = false
|
|
|
|
|
|
|
|
def up
|
2021-04-13 12:11:32 +00:00
|
|
|
return unless should_run?
|
2021-03-31 00:09:32 +00:00
|
|
|
|
|
|
|
backfill_conversion_of_integer_to_bigint :push_event_payloads, :event_id, primary_key: :event_id,
|
2022-08-02 12:09:26 +00:00
|
|
|
batch_size: 15000, sub_batch_size: 100
|
2021-03-31 00:09:32 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
def down
|
2021-04-13 12:11:32 +00:00
|
|
|
return unless should_run?
|
2021-03-31 00:09:32 +00:00
|
|
|
|
|
|
|
Gitlab::Database::BackgroundMigration::BatchedMigration
|
|
|
|
.where(job_class_name: 'CopyColumnUsingBackgroundMigrationJob')
|
|
|
|
.where(table_name: 'push_event_payloads', column_name: 'event_id')
|
2021-04-26 12:09:44 +00:00
|
|
|
.where(job_arguments: %w[event_id event_id_convert_to_bigint].to_json)
|
2021-03-31 00:09:32 +00:00
|
|
|
.delete_all
|
|
|
|
end
|
2021-04-13 12:11:32 +00:00
|
|
|
|
|
|
|
private
|
|
|
|
|
|
|
|
def should_run?
|
|
|
|
Gitlab.dev_or_test_env? || Gitlab.com?
|
|
|
|
end
|
2021-03-31 00:09:32 +00:00
|
|
|
end
|