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/20220603173103_update_vulnerabilities_project_id_id_index.rb')
-rw-r--r--db/post_migrate/20220603173103_update_vulnerabilities_project_id_id_index.rb22
1 files changed, 22 insertions, 0 deletions
diff --git a/db/post_migrate/20220603173103_update_vulnerabilities_project_id_id_index.rb b/db/post_migrate/20220603173103_update_vulnerabilities_project_id_id_index.rb
new file mode 100644
index 00000000000..8f10fd61273
--- /dev/null
+++ b/db/post_migrate/20220603173103_update_vulnerabilities_project_id_id_index.rb
@@ -0,0 +1,22 @@
+# frozen_string_literal: true
+
+class UpdateVulnerabilitiesProjectIdIdIndex < Gitlab::Database::Migration[2.0]
+ disable_ddl_transaction!
+
+ NEW_INDEX_NAME = 'idx_vulnerabilities_partial_devops_adoption_and_default_branch'
+ OLD_INDEX_NAME = 'idx_vulnerabilities_partial_devops_adoption'
+
+ def up
+ add_concurrent_index :vulnerabilities, [:project_id, :created_at, :present_on_default_branch],
+ where: 'state != 1',
+ name: NEW_INDEX_NAME
+
+ remove_concurrent_index_by_name(:vulnerabilities, OLD_INDEX_NAME)
+ end
+
+ def down
+ add_concurrent_index :vulnerabilities, [:project_id, :created_at], where: 'state != 1', name: OLD_INDEX_NAME
+
+ remove_concurrent_index_by_name(:vulnerabilities, NEW_INDEX_NAME)
+ end
+end