Skip to content

Commit 7eae80f

Browse files
Omar QunsulTianwen Chen
andcommitted
Merge branch '412862-index' into 'master'
Create concurrent index for pipeline_id_convert_to_bigint See merge request https://gitlab.com/gitlab-org/gitlab/-/merge_requests/128716 Merged-by: Omar Qunsul <[email protected]> Approved-by: Jarka Košanová <[email protected]> Approved-by: Omar Qunsul <[email protected]> Reviewed-by: Tianwen Chen <[email protected]> Co-authored-by: Tianwen Chen <[email protected]>
2 parents 25df1ab + 81238f7 commit 7eae80f

5 files changed

+44
-0
lines changed
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
# frozen_string_literal: true
2+
3+
class EnsureBackfillForCiPipelineChatDataPipelineIdIsFinished < Gitlab::Database::Migration[2.1]
4+
include Gitlab::Database::MigrationHelpers::ConvertToBigint
5+
6+
restrict_gitlab_migration gitlab_schema: :gitlab_ci
7+
disable_ddl_transaction!
8+
9+
TABLE_NAME = :ci_pipeline_chat_data
10+
11+
def up
12+
ensure_batched_background_migration_is_finished(
13+
job_class_name: 'CopyColumnUsingBackgroundMigrationJob',
14+
table_name: TABLE_NAME,
15+
column_name: 'id',
16+
job_arguments: [['pipeline_id'], ['pipeline_id_convert_to_bigint']]
17+
)
18+
end
19+
20+
def down
21+
# no-op
22+
end
23+
end
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
# frozen_string_literal: true
2+
3+
class AddConcurrentIndexForCiPipelineChatDataPipelineIdConvertToBigint < Gitlab::Database::Migration[2.1]
4+
disable_ddl_transaction!
5+
6+
INDEX_NAME = "index_ci_pipeline_chat_data_on_pipeline_id_convert_to_bigint"
7+
TABLE_NAME = :ci_pipeline_chat_data
8+
COLUMN_NAME = :pipeline_id_convert_to_bigint
9+
10+
def up
11+
add_concurrent_index TABLE_NAME, COLUMN_NAME, name: INDEX_NAME, unique: true
12+
end
13+
14+
def down
15+
remove_concurrent_index_by_name TABLE_NAME, name: INDEX_NAME
16+
end
17+
end

db/schema_migrations/20230901054536

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
789900a0db2f180bdeebc5fcd7fcb446f23e2ea77bd7f62e682779e75c981290

db/schema_migrations/20230901064536

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
0097ccb7ec94655f8f455ae52f2a20089833a584f9f307ba554cd2c91f41e677

db/structure.sql

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31115,6 +31115,8 @@ CREATE INDEX index_ci_pipeline_chat_data_on_chat_name_id ON ci_pipeline_chat_dat
3111531115

3111631116
CREATE UNIQUE INDEX index_ci_pipeline_chat_data_on_pipeline_id ON ci_pipeline_chat_data USING btree (pipeline_id);
3111731117

31118+
CREATE UNIQUE INDEX index_ci_pipeline_chat_data_on_pipeline_id_convert_to_bigint ON ci_pipeline_chat_data USING btree (pipeline_id_convert_to_bigint);
31119+
3111831120
CREATE INDEX index_ci_pipeline_messages_on_pipeline_id ON ci_pipeline_messages USING btree (pipeline_id);
3111931121

3112031122
CREATE INDEX index_ci_pipeline_metadata_on_project_id ON ci_pipeline_metadata USING btree (project_id);

0 commit comments

Comments
 (0)