From 00111df5bff95a15a66f0426b44f82b71763331a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Manuel=20Sch=C3=B6nlaub?= <manuel.schoenlaub@gmail.com> Date: Thu, 20 Feb 2025 08:55:38 +0000 Subject: [PATCH] Prepare async migration to add ID to index on pipeline This is done to improve performance in the CommitController. --- ..._pipelines_on_project_id_and_sha_and_id.rb | 19 +++++++++++++++++++ db/schema_migrations/20250127184534 | 1 + 2 files changed, 20 insertions(+) create mode 100644 db/post_migrate/20250127184534_schedule_index_ci_pipelines_on_project_id_and_sha_and_id.rb create mode 100644 db/schema_migrations/20250127184534 diff --git a/db/post_migrate/20250127184534_schedule_index_ci_pipelines_on_project_id_and_sha_and_id.rb b/db/post_migrate/20250127184534_schedule_index_ci_pipelines_on_project_id_and_sha_and_id.rb new file mode 100644 index 000000000000..5270392f1809 --- /dev/null +++ b/db/post_migrate/20250127184534_schedule_index_ci_pipelines_on_project_id_and_sha_and_id.rb @@ -0,0 +1,19 @@ +# frozen_string_literal: true + +class ScheduleIndexCiPipelinesOnProjectIdAndShaAndId < Gitlab::Database::Migration[2.2] + milestone '17.9' + disable_ddl_transaction! + + TABLE_NAME = :ci_pipelines + COLUMN_NAMES = [:project_id, :sha, :id] + INDEX_NAME = 'ci_pipelines_on_project_id_and_sha_and_id' + + # TODO: Index to be created synchronously in https://gitlab.com/gitlab-org/gitlab/-/issues/516073 + def up + prepare_async_index(TABLE_NAME, COLUMN_NAMES, name: INDEX_NAME) + end + + def down + unprepare_async_index(TABLE_NAME, COLUMN_NAMES, name: INDEX_NAME) + end +end diff --git a/db/schema_migrations/20250127184534 b/db/schema_migrations/20250127184534 new file mode 100644 index 000000000000..95a0afaca717 --- /dev/null +++ b/db/schema_migrations/20250127184534 @@ -0,0 +1 @@ +ab8ee7d18e100a78130cad7d073316497d623ff6005ee38a3bdc549664b9e7b4 \ No newline at end of file -- GitLab