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/migrate/20201215132151_change_unique_index_on_security_findings.rb')
-rw-r--r--db/migrate/20201215132151_change_unique_index_on_security_findings.rb36
1 files changed, 0 insertions, 36 deletions
diff --git a/db/migrate/20201215132151_change_unique_index_on_security_findings.rb b/db/migrate/20201215132151_change_unique_index_on_security_findings.rb
deleted file mode 100644
index fe474ef3991..00000000000
--- a/db/migrate/20201215132151_change_unique_index_on_security_findings.rb
+++ /dev/null
@@ -1,36 +0,0 @@
-# frozen_string_literal: true
-
-class ChangeUniqueIndexOnSecurityFindings < ActiveRecord::Migration[6.0]
- include Gitlab::Database::MigrationHelpers
-
- DOWNTIME = false
- OLD_INDEX_NAME = 'index_security_findings_on_uuid'
- NEW_INDEX_NAME = 'index_security_findings_on_uuid_and_scan_id'
-
- disable_ddl_transaction!
-
- class SecurityFinding < ActiveRecord::Base
- include EachBatch
-
- self.table_name = 'security_findings'
- end
-
- def up
- add_concurrent_index :security_findings, [:uuid, :scan_id], unique: true, name: NEW_INDEX_NAME
-
- remove_concurrent_index_by_name :security_findings, OLD_INDEX_NAME
- end
-
- def down
- # It is very unlikely that we rollback this migration but just in case if we have to,
- # we have to clear the table because there can be multiple records with the same UUID
- # which would break the creation of unique index on the `uuid` column.
- # We choose clearing the table because just removing the duplicated records would
- # cause data inconsistencies.
- SecurityFinding.each_batch(of: 10000) { |relation| relation.delete_all }
-
- add_concurrent_index :security_findings, :uuid, unique: true, name: OLD_INDEX_NAME
-
- remove_concurrent_index_by_name :security_findings, NEW_INDEX_NAME
- end
-end