summaryrefslogtreecommitdiff
path: root/db/migrate/20200414114611_add_group_id_index_and_fk_to_vulnerability_exports.rb
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2020-05-20 14:34:42 +0000
committerGitLab Bot <gitlab-bot@gitlab.com>2020-05-20 14:34:42 +0000
commit9f46488805e86b1bc341ea1620b866016c2ce5ed (patch)
treef9748c7e287041e37d6da49e0a29c9511dc34768 /db/migrate/20200414114611_add_group_id_index_and_fk_to_vulnerability_exports.rb
parentdfc92d081ea0332d69c8aca2f0e745cb48ae5e6d (diff)
downloadgitlab-ce-9f46488805e86b1bc341ea1620b866016c2ce5ed.tar.gz
Add latest changes from gitlab-org/gitlab@13-0-stable-ee
Diffstat (limited to 'db/migrate/20200414114611_add_group_id_index_and_fk_to_vulnerability_exports.rb')
-rw-r--r--db/migrate/20200414114611_add_group_id_index_and_fk_to_vulnerability_exports.rb20
1 files changed, 20 insertions, 0 deletions
diff --git a/db/migrate/20200414114611_add_group_id_index_and_fk_to_vulnerability_exports.rb b/db/migrate/20200414114611_add_group_id_index_and_fk_to_vulnerability_exports.rb
new file mode 100644
index 00000000000..a3e60b87857
--- /dev/null
+++ b/db/migrate/20200414114611_add_group_id_index_and_fk_to_vulnerability_exports.rb
@@ -0,0 +1,20 @@
+# frozen_string_literal: true
+
+class AddGroupIdIndexAndFkToVulnerabilityExports < ActiveRecord::Migration[6.0]
+ include Gitlab::Database::MigrationHelpers
+
+ DOWNTIME = false
+ GROUP_ID_INDEX_NAME = 'index_vulnerability_exports_on_group_id_not_null'
+
+ disable_ddl_transaction!
+
+ def up
+ add_concurrent_index(:vulnerability_exports, :group_id, where: 'group_id IS NOT NULL', name: GROUP_ID_INDEX_NAME)
+ add_concurrent_foreign_key(:vulnerability_exports, :namespaces, column: :group_id)
+ end
+
+ def down
+ remove_foreign_key(:vulnerability_exports, column: :group_id)
+ remove_concurrent_index_by_name(:vulnerability_exports, GROUP_ID_INDEX_NAME)
+ end
+end