summaryrefslogtreecommitdiff
path: root/db/post_migrate/20230511132140_create_component_id_index.rb
diff options
context:
space:
mode:
Diffstat (limited to 'db/post_migrate/20230511132140_create_component_id_index.rb')
-rw-r--r--db/post_migrate/20230511132140_create_component_id_index.rb17
1 files changed, 17 insertions, 0 deletions
diff --git a/db/post_migrate/20230511132140_create_component_id_index.rb b/db/post_migrate/20230511132140_create_component_id_index.rb
new file mode 100644
index 00000000000..3b466010f7c
--- /dev/null
+++ b/db/post_migrate/20230511132140_create_component_id_index.rb
@@ -0,0 +1,17 @@
+# frozen_string_literal: true
+
+class CreateComponentIdIndex < Gitlab::Database::Migration[2.1]
+ disable_ddl_transaction!
+
+ INDEX_NAME = 'index_sbom_occurrences_on_project_id_component_id'
+
+ def up
+ return if index_exists_by_name?(:sbom_occurrences, INDEX_NAME)
+
+ add_concurrent_index :sbom_occurrences, [:project_id, :component_id], name: INDEX_NAME
+ end
+
+ def down
+ remove_concurrent_index_by_name :sbom_sources, INDEX_NAME
+ end
+end