summaryrefslogtreecommitdiff
path: root/db/migrate/20191001040549_add_management_project_id_index_fk_to_clusters.rb
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2019-10-14 12:06:14 +0000
committerGitLab Bot <gitlab-bot@gitlab.com>2019-10-14 12:06:14 +0000
commite464f195ff5debc3e9aad0f8c4537404b92019c6 (patch)
tree9efe381ffb9d8c9bceb3cced1e27b6b59dc6298b /db/migrate/20191001040549_add_management_project_id_index_fk_to_clusters.rb
parent5ff1b520badaa2da217416964709f49f3ede350a (diff)
downloadgitlab-ce-e464f195ff5debc3e9aad0f8c4537404b92019c6.tar.gz
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'db/migrate/20191001040549_add_management_project_id_index_fk_to_clusters.rb')
-rw-r--r--db/migrate/20191001040549_add_management_project_id_index_fk_to_clusters.rb19
1 files changed, 19 insertions, 0 deletions
diff --git a/db/migrate/20191001040549_add_management_project_id_index_fk_to_clusters.rb b/db/migrate/20191001040549_add_management_project_id_index_fk_to_clusters.rb
new file mode 100644
index 00000000000..97253dd1f2d
--- /dev/null
+++ b/db/migrate/20191001040549_add_management_project_id_index_fk_to_clusters.rb
@@ -0,0 +1,19 @@
+# frozen_string_literal: true
+
+class AddManagementProjectIdIndexFkToClusters < ActiveRecord::Migration[5.2]
+ include Gitlab::Database::MigrationHelpers
+
+ DOWNTIME = false
+
+ disable_ddl_transaction!
+
+ def up
+ add_concurrent_foreign_key :clusters, :projects, column: :management_project_id, on_delete: :nullify
+ add_concurrent_index :clusters, :management_project_id, where: 'management_project_id IS NOT NULL'
+ end
+
+ def down
+ remove_concurrent_index :clusters, :management_project_id
+ remove_foreign_key_if_exists :clusters, column: :management_project_id
+ end
+end