Commit e0574593 authored by Krasimir Angelov's avatar Krasimir Angelov Committed by Adam Hegyi

Prepare indexes on events for bigint column conversions

Add migration to create indexes asynchronously for the `events` table.
Creating the indexes asynchronously will preventing the column swap
migration from running for an excessive length of time.

Changelog: other
parent 457ef961
# frozen_string_literal: true
class PrepareIndexesForEventsBigintConversion < ActiveRecord::Migration[6.1]
include Gitlab::Database::MigrationHelpers
TABLE_NAME = 'events'
def up
prepare_async_index TABLE_NAME, :id_convert_to_bigint, unique: true,
name: :index_events_on_id_convert_to_bigint
prepare_async_index TABLE_NAME, [:project_id, :id_convert_to_bigint],
name: :index_events_on_project_id_and_id_convert_to_bigint
prepare_async_index TABLE_NAME, [:project_id, :id_convert_to_bigint], order: { id_convert_to_bigint: :desc },
where: 'action = 7', name: :index_events_on_project_id_and_id_bigint_desc_on_merged_action
end
def down
unprepare_async_index_by_name TABLE_NAME, :index_events_on_id_convert_to_bigint
unprepare_async_index_by_name TABLE_NAME, :index_events_on_project_id_and_id_convert_to_bigint
unprepare_async_index_by_name TABLE_NAME, :index_events_on_project_id_and_id_bigint_desc_on_merged_action
end
end
360bb1c16c93d7a6564ed70fa2dea4212e1fd00d101cfdc9017b54f67eae797d
\ No newline at end of file
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