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/20230724212040_add_temporary_indexes_for_orphaned_approval_rules.rb')
-rw-r--r--db/post_migrate/20230724212040_add_temporary_indexes_for_orphaned_approval_rules.rb27
1 files changed, 27 insertions, 0 deletions
diff --git a/db/post_migrate/20230724212040_add_temporary_indexes_for_orphaned_approval_rules.rb b/db/post_migrate/20230724212040_add_temporary_indexes_for_orphaned_approval_rules.rb
new file mode 100644
index 00000000000..69e5f7d48ac
--- /dev/null
+++ b/db/post_migrate/20230724212040_add_temporary_indexes_for_orphaned_approval_rules.rb
@@ -0,0 +1,27 @@
+# frozen_string_literal: true
+
+class AddTemporaryIndexesForOrphanedApprovalRules < Gitlab::Database::Migration[2.1]
+ disable_ddl_transaction!
+
+ LICENSE_SCANNING = 2
+ SCAN_FINDING = 4
+
+ TMP_PROJECT_INDEX_NAME = 'tmp_idx_orphaned_approval_project_rules'
+ TMP_MR_INDEX_NAME = 'tmp_idx_orphaned_approval_merge_request_rules'
+
+ def up
+ add_concurrent_index('approval_project_rules', :id, where: query_condition, name: TMP_PROJECT_INDEX_NAME)
+ add_concurrent_index('approval_merge_request_rules', :id, where: query_condition, name: TMP_MR_INDEX_NAME)
+ end
+
+ def down
+ remove_concurrent_index_by_name('approval_project_rules', TMP_PROJECT_INDEX_NAME)
+ remove_concurrent_index_by_name('approval_merge_request_rules', TMP_MR_INDEX_NAME)
+ end
+
+ private
+
+ def query_condition
+ "report_type IN (#{LICENSE_SCANNING}, #{SCAN_FINDING}) AND security_orchestration_policy_configuration_id IS NULL"
+ end
+end