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/20201005092703_add_namespace_column_to_frameworks.rb')
-rw-r--r--db/migrate/20201005092703_add_namespace_column_to_frameworks.rb26
1 files changed, 26 insertions, 0 deletions
diff --git a/db/migrate/20201005092703_add_namespace_column_to_frameworks.rb b/db/migrate/20201005092703_add_namespace_column_to_frameworks.rb
new file mode 100644
index 00000000000..b7a9866e50b
--- /dev/null
+++ b/db/migrate/20201005092703_add_namespace_column_to_frameworks.rb
@@ -0,0 +1,26 @@
+# frozen_string_literal: true
+
+class AddNamespaceColumnToFrameworks < ActiveRecord::Migration[6.0]
+ include Gitlab::Database::MigrationHelpers
+
+ DOWNTIME = false
+ INDEX_NAME = 'idx_on_compliance_management_frameworks_namespace_id_name'
+
+ disable_ddl_transaction!
+
+ def up
+ unless column_exists?(:compliance_management_frameworks, :namespace_id)
+ add_column(:compliance_management_frameworks, :namespace_id, :integer)
+ end
+
+ add_concurrent_foreign_key(:compliance_management_frameworks, :namespaces, column: :namespace_id, on_delete: :cascade)
+ add_concurrent_index(:compliance_management_frameworks, [:namespace_id, :name], unique: true, name: INDEX_NAME)
+ end
+
+ def down
+ remove_concurrent_index_by_name(:compliance_management_frameworks, INDEX_NAME)
+ remove_foreign_key_if_exists(:compliance_management_frameworks, :namespaces, column: :namespace_id)
+
+ remove_column(:compliance_management_frameworks, :namespace_id)
+ end
+end