parent
98c8c90e92
commit
e9657acfc3
3 changed files with 41 additions and 0 deletions
|
@ -0,0 +1,5 @@
|
||||||
|
---
|
||||||
|
title: Ensure foreign keys on clusters applications
|
||||||
|
merge_request: 17488
|
||||||
|
author:
|
||||||
|
type: other
|
|
@ -0,0 +1,34 @@
|
||||||
|
# See http://doc.gitlab.com/ce/development/migration_style_guide.html
|
||||||
|
# for more information on how to write migrations for GitLab.
|
||||||
|
|
||||||
|
class EnsureForeignKeysOnClustersApplications < ActiveRecord::Migration
|
||||||
|
include Gitlab::Database::MigrationHelpers
|
||||||
|
|
||||||
|
DOWNTIME = false
|
||||||
|
|
||||||
|
disable_ddl_transaction!
|
||||||
|
|
||||||
|
def up
|
||||||
|
unless foreign_keys_for(:clusters_applications_ingress, :cluster_id).any?
|
||||||
|
add_concurrent_foreign_key :clusters_applications_ingress, :clusters,
|
||||||
|
column: :cluster_id,
|
||||||
|
on_delete: :cascade
|
||||||
|
end
|
||||||
|
|
||||||
|
unless foreign_keys_for(:clusters_applications_prometheus, :cluster_id).any?
|
||||||
|
add_concurrent_foreign_key :clusters_applications_prometheus, :clusters,
|
||||||
|
column: :cluster_id,
|
||||||
|
on_delete: :cascade
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
def down
|
||||||
|
if foreign_keys_for(:clusters_applications_ingress, :cluster_id).any?
|
||||||
|
remove_foreign_key :clusters_applications_ingress, column: :cluster_id
|
||||||
|
end
|
||||||
|
|
||||||
|
if foreign_keys_for(:clusters_applications_prometheus, :cluster_id).any?
|
||||||
|
remove_foreign_key :clusters_applications_prometheus, column: :cluster_id
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
|
@ -2028,6 +2028,8 @@ ActiveRecord::Schema.define(version: 20180307012445) do
|
||||||
add_foreign_key "cluster_providers_gcp", "clusters", on_delete: :cascade
|
add_foreign_key "cluster_providers_gcp", "clusters", on_delete: :cascade
|
||||||
add_foreign_key "clusters", "users", on_delete: :nullify
|
add_foreign_key "clusters", "users", on_delete: :nullify
|
||||||
add_foreign_key "clusters_applications_helm", "clusters", on_delete: :cascade
|
add_foreign_key "clusters_applications_helm", "clusters", on_delete: :cascade
|
||||||
|
add_foreign_key "clusters_applications_ingress", "clusters", on_delete: :cascade
|
||||||
|
add_foreign_key "clusters_applications_prometheus", "clusters", on_delete: :cascade
|
||||||
add_foreign_key "clusters_applications_runners", "ci_runners", column: "runner_id", name: "fk_02de2ded36", on_delete: :nullify
|
add_foreign_key "clusters_applications_runners", "ci_runners", column: "runner_id", name: "fk_02de2ded36", on_delete: :nullify
|
||||||
add_foreign_key "clusters_applications_runners", "clusters", on_delete: :cascade
|
add_foreign_key "clusters_applications_runners", "clusters", on_delete: :cascade
|
||||||
add_foreign_key "container_repositories", "projects"
|
add_foreign_key "container_repositories", "projects"
|
||||||
|
|
Loading…
Reference in a new issue