diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2024-01-10 22:04:15 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2024-01-10 22:04:15 +0300 |
commit | c1c8ecf7b5a40a8ca7434ce91c444556a499e769 (patch) | |
tree | 809cc9e5f83afe609ac640bc99908bb08914d8f6 /db/post_migrate | |
parent | 28a032c698aedcb223d386b4aaef25fef098ef44 (diff) |
Add latest changes from gitlab-org/gitlab@16-5-stable-ee
Diffstat (limited to 'db/post_migrate')
-rw-r--r-- | db/post_migrate/20231004091113_swap_columns_for_ci_sources_pipelines_pipeline_id_bigint.rb | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/db/post_migrate/20231004091113_swap_columns_for_ci_sources_pipelines_pipeline_id_bigint.rb b/db/post_migrate/20231004091113_swap_columns_for_ci_sources_pipelines_pipeline_id_bigint.rb index 6ce4e1a4da5..d7b274be29f 100644 --- a/db/post_migrate/20231004091113_swap_columns_for_ci_sources_pipelines_pipeline_id_bigint.rb +++ b/db/post_migrate/20231004091113_swap_columns_for_ci_sources_pipelines_pipeline_id_bigint.rb @@ -36,6 +36,8 @@ class SwapColumnsForCiSourcesPipelinesPipelineIdBigint < Gitlab::Database::Migra private def swap + ensure_indexes_exist + with_lock_retries(raise_on_exhaustion: true) do # Lock the tables involved. execute "LOCK TABLE #{TARGET_TABLE_NAME}, #{TABLE_NAME} IN ACCESS EXCLUSIVE MODE" @@ -74,4 +76,14 @@ class SwapColumnsForCiSourcesPipelinesPipelineIdBigint < Gitlab::Database::Migra end end end + + def ensure_indexes_exist + unless index_exists?(TABLE_NAME, :pipeline_id, name: :index_ci_sources_pipelines_on_pipeline_id) + add_concurrent_index(TABLE_NAME, :pipeline_id, name: :index_ci_sources_pipelines_on_pipeline_id) + end + + return if index_exists?(TABLE_NAME, :source_pipeline_id, name: :index_ci_sources_pipelines_on_source_pipeline_id) + + add_concurrent_index(TABLE_NAME, :source_pipeline_id, name: :index_ci_sources_pipelines_on_source_pipeline_id) + end end |