summaryrefslogtreecommitdiff
path: root/db/migrate/20200423081519_add_foreign_key_from_projects_to_metrics_users_starred_dashboars.rb
diff options
context:
space:
mode:
Diffstat (limited to 'db/migrate/20200423081519_add_foreign_key_from_projects_to_metrics_users_starred_dashboars.rb')
-rw-r--r--db/migrate/20200423081519_add_foreign_key_from_projects_to_metrics_users_starred_dashboars.rb18
1 files changed, 18 insertions, 0 deletions
diff --git a/db/migrate/20200423081519_add_foreign_key_from_projects_to_metrics_users_starred_dashboars.rb b/db/migrate/20200423081519_add_foreign_key_from_projects_to_metrics_users_starred_dashboars.rb
new file mode 100644
index 00000000000..88565c24eca
--- /dev/null
+++ b/db/migrate/20200423081519_add_foreign_key_from_projects_to_metrics_users_starred_dashboars.rb
@@ -0,0 +1,18 @@
+# frozen_string_literal: true
+
+class AddForeignKeyFromProjectsToMetricsUsersStarredDashboars < ActiveRecord::Migration[6.0]
+ include Gitlab::Database::MigrationHelpers
+
+ DOWNTIME = false
+ disable_ddl_transaction!
+
+ def up
+ add_concurrent_foreign_key :metrics_users_starred_dashboards, :projects, column: :project_id, on_delete: :cascade
+ end
+
+ def down
+ with_lock_retries do
+ remove_foreign_key_if_exists :metrics_users_starred_dashboards, column: :project_id
+ end
+ end
+end