summaryrefslogtreecommitdiff
path: root/db/migrate/20220818140553_add_unique_index_to_sbom_occurrences_on_ingestion_attributes.rb
diff options
context:
space:
mode:
Diffstat (limited to 'db/migrate/20220818140553_add_unique_index_to_sbom_occurrences_on_ingestion_attributes.rb')
-rw-r--r--db/migrate/20220818140553_add_unique_index_to_sbom_occurrences_on_ingestion_attributes.rb22
1 files changed, 22 insertions, 0 deletions
diff --git a/db/migrate/20220818140553_add_unique_index_to_sbom_occurrences_on_ingestion_attributes.rb b/db/migrate/20220818140553_add_unique_index_to_sbom_occurrences_on_ingestion_attributes.rb
new file mode 100644
index 00000000000..2538017e287
--- /dev/null
+++ b/db/migrate/20220818140553_add_unique_index_to_sbom_occurrences_on_ingestion_attributes.rb
@@ -0,0 +1,22 @@
+# frozen_string_literal: true
+
+class AddUniqueIndexToSbomOccurrencesOnIngestionAttributes < Gitlab::Database::Migration[2.0]
+ INDEX_NAME = 'index_sbom_occurrences_on_ingestion_attributes'
+ ATTRIBUTES = %i[
+ project_id
+ component_id
+ component_version_id
+ source_id
+ commit_sha
+ ].freeze
+
+ disable_ddl_transaction!
+
+ def up
+ add_concurrent_index :sbom_occurrences, ATTRIBUTES, unique: true, name: INDEX_NAME
+ end
+
+ def down
+ remove_concurrent_index_by_name :sbom_occurrences, name: INDEX_NAME
+ end
+end