Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'db/migrate/20221202202351_remove_index_i_ci_job_token_project_scope_links_on_source_and_target_project.rb')
-rw-r--r--db/migrate/20221202202351_remove_index_i_ci_job_token_project_scope_links_on_source_and_target_project.rb23
1 files changed, 23 insertions, 0 deletions
diff --git a/db/migrate/20221202202351_remove_index_i_ci_job_token_project_scope_links_on_source_and_target_project.rb b/db/migrate/20221202202351_remove_index_i_ci_job_token_project_scope_links_on_source_and_target_project.rb
new file mode 100644
index 00000000000..81a636739b4
--- /dev/null
+++ b/db/migrate/20221202202351_remove_index_i_ci_job_token_project_scope_links_on_source_and_target_project.rb
@@ -0,0 +1,23 @@
+# frozen_string_literal: true
+class RemoveIndexICiJobTokenProjectScopeLinksOnSourceAndTargetProject < Gitlab::Database::Migration[2.0]
+ disable_ddl_transaction!
+
+ TABLE_NAME = 'ci_job_token_project_scope_links'
+ OLD_INDEX_NAME = 'i_ci_job_token_project_scope_links_on_source_and_target_project'
+ NEW_INDEX_NAME = 'ci_job_token_scope_links_source_and_target_project_direction'
+ NEW_INDEX_COL = %w[source_project_id target_project_id direction]
+
+ def up
+ add_concurrent_index(
+ TABLE_NAME,
+ NEW_INDEX_COL,
+ name: NEW_INDEX_NAME,
+ unique: true
+ )
+ remove_concurrent_index_by_name(TABLE_NAME, OLD_INDEX_NAME)
+ end
+
+ def down
+ # noop: as we can have duplicate records once the unique index is removed
+ end
+end