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/post_migrate/20220715191629_change_primary_key_of_security_findings_table.rb')
-rw-r--r--db/post_migrate/20220715191629_change_primary_key_of_security_findings_table.rb29
1 files changed, 29 insertions, 0 deletions
diff --git a/db/post_migrate/20220715191629_change_primary_key_of_security_findings_table.rb b/db/post_migrate/20220715191629_change_primary_key_of_security_findings_table.rb
new file mode 100644
index 00000000000..c2859c68c52
--- /dev/null
+++ b/db/post_migrate/20220715191629_change_primary_key_of_security_findings_table.rb
@@ -0,0 +1,29 @@
+# frozen_string_literal: true
+
+class ChangePrimaryKeyOfSecurityFindingsTable < Gitlab::Database::Migration[2.0]
+ enable_lock_retries!
+
+ def up
+ execute(<<~SQL)
+ ALTER TABLE security_findings DROP CONSTRAINT security_findings_pkey;
+ SQL
+
+ execute(<<~SQL)
+ ALTER TABLE security_findings ADD CONSTRAINT security_findings_pkey PRIMARY KEY USING index security_findings_partitioned_pkey;
+ SQL
+ end
+
+ def down
+ execute(<<~SQL)
+ ALTER TABLE security_findings DROP CONSTRAINT security_findings_pkey;
+ SQL
+
+ execute(<<~SQL)
+ ALTER TABLE security_findings ADD CONSTRAINT security_findings_pkey PRIMARY KEY (id);
+ SQL
+
+ execute(<<~SQL)
+ CREATE UNIQUE INDEX security_findings_partitioned_pkey ON security_findings USING btree(id, partition_number);
+ SQL
+ end
+end