Commit e09fc697 authored by pbair's avatar pbair

Prepare indexes for bigint column conversions

Add migrations to create indexes asynchronously for tables that need to
have columns converted from int to bigint. Creating the indexes
asynchronously will preventing the column swap migrations from running
for an excessive length of time.

Changelog: other
parent e7ea1609
# frozen_string_literal: true
class PrepareIndexesForCiJobArtifactBigintConversion < ActiveRecord::Migration[6.1]
include Gitlab::Database::MigrationHelpers
def up
prepare_async_index :ci_job_artifacts, :id_convert_to_bigint, unique: true,
name: :index_ci_job_artifact_on_id_convert_to_bigint
prepare_async_index :ci_job_artifacts, [:project_id, :id_convert_to_bigint], where: 'file_type = 18',
name: :index_ci_job_artifacts_for_terraform_reports_bigint
prepare_async_index :ci_job_artifacts, :id_convert_to_bigint, where: 'file_type = 18',
name: :index_ci_job_artifacts_id_for_terraform_reports_bigint
prepare_async_index :ci_job_artifacts, [:expire_at, :job_id_convert_to_bigint],
name: :index_ci_job_artifacts_on_expire_at_and_job_id_bigint
prepare_async_index :ci_job_artifacts, [:job_id_convert_to_bigint, :file_type], unique: true,
name: :index_ci_job_artifacts_on_job_id_and_file_type_bigint
end
def down
unprepare_async_index_by_name :ci_job_artifacts, :index_ci_job_artifacts_on_job_id_and_file_type_bigint
unprepare_async_index_by_name :ci_job_artifacts, :index_ci_job_artifacts_on_expire_at_and_job_id_bigint
unprepare_async_index_by_name :ci_job_artifacts, :index_ci_job_artifacts_id_for_terraform_reports_bigint
unprepare_async_index_by_name :ci_job_artifacts, :index_ci_job_artifacts_for_terraform_reports_bigint
unprepare_async_index_by_name :ci_job_artifacts, :index_ci_job_artifact_on_id_convert_to_bigint
end
end
# frozen_string_literal: true
class PrepareIndexesForTaggingBigintConversion < ActiveRecord::Migration[6.1]
include Gitlab::Database::MigrationHelpers
def up
prepare_async_index :taggings, :id_convert_to_bigint, unique: true,
name: :index_taggings_on_id_convert_to_bigint
prepare_async_index :taggings, [:taggable_id_convert_to_bigint, :taggable_type],
name: :i_taggings_on_taggable_id_convert_to_bigint_and_taggable_type
prepare_async_index :taggings, [:taggable_id_convert_to_bigint, :taggable_type, :context],
name: :i_taggings_on_taggable_bigint_and_taggable_type_and_context
prepare_async_index :taggings, [:tag_id, :taggable_id_convert_to_bigint, :taggable_type, :context, :tagger_id, :tagger_type],
unique: true, name: :taggings_idx_tmp
end
def down
unprepare_async_index_by_name :taggings, :taggings_idx_tmp
unprepare_async_index_by_name :taggings, :i_taggings_on_taggable_bigint_and_taggable_type_and_context
unprepare_async_index_by_name :taggings, :i_taggings_on_taggable_id_convert_to_bigint_and_taggable_type
unprepare_async_index_by_name :taggings, :index_taggings_on_id_convert_to_bigint
end
end
# frozen_string_literal: true
class PrepareIndexesForCiStageBigintConversion < ActiveRecord::Migration[6.1]
include Gitlab::Database::MigrationHelpers
def up
prepare_async_index :ci_stages, :id_convert_to_bigint, unique: true,
name: :index_ci_stages_on_id_convert_to_bigint
prepare_async_index :ci_stages, [:pipeline_id, :id_convert_to_bigint], where: 'status in (0, 1, 2, 8, 9, 10)',
name: :index_ci_stages_on_pipeline_id_and_id_convert_to_bigint
end
def down
unprepare_async_index_by_name :ci_stages, :index_ci_stages_on_pipeline_id_and_id_convert_to_bigint
unprepare_async_index_by_name :ci_stages, :index_ci_stages_on_id_convert_to_bigint
end
end
4a6676e9185a99070751c91c71a7a9e6a845426d68567abf80a2e414251e5805
\ No newline at end of file
d73756410c7f37662c50bb05c372e6ac32ba81f232c07debcd42d1f679eb74ef
\ No newline at end of file
ab7ee98704e844de4a3ba3ae14ea64dd46539e63d49c7c7e0d67ed03ebc3bbd4
\ 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