From aa041347858f921be80d0b7cda2dda6f5011a791 Mon Sep 17 00:00:00 2001 From: Karina Kwiatek Date: Sat, 16 Jul 2022 20:10:51 +0200 Subject: [PATCH] Remove foreign key constraints from anon blocks & mute rules We do it this way on other tables. Rails validates these on its own anyway. --- .../20220714211614_set_on_delete_for_anonymous_blocks.rb | 4 ++-- db/migrate/20220714212414_set_on_delete_for_mute_rules.rb | 2 +- db/schema.rb | 3 --- 3 files changed, 3 insertions(+), 6 deletions(-) diff --git a/db/migrate/20220714211614_set_on_delete_for_anonymous_blocks.rb b/db/migrate/20220714211614_set_on_delete_for_anonymous_blocks.rb index 52aaf299..627d6af4 100644 --- a/db/migrate/20220714211614_set_on_delete_for_anonymous_blocks.rb +++ b/db/migrate/20220714211614_set_on_delete_for_anonymous_blocks.rb @@ -3,8 +3,8 @@ class SetOnDeleteForAnonymousBlocks < ActiveRecord::Migration[6.1] def change change_table :anonymous_blocks do |t| - t.foreign_key :users, on_delete: :cascade - t.foreign_key :questions, on_delete: :cascade + t.remove_foreign_key :users + t.remove_foreign_key :questions end end end diff --git a/db/migrate/20220714212414_set_on_delete_for_mute_rules.rb b/db/migrate/20220714212414_set_on_delete_for_mute_rules.rb index d4c01c6b..2f2a84f8 100644 --- a/db/migrate/20220714212414_set_on_delete_for_mute_rules.rb +++ b/db/migrate/20220714212414_set_on_delete_for_mute_rules.rb @@ -3,7 +3,7 @@ class SetOnDeleteForMuteRules < ActiveRecord::Migration[6.1] def change change_table :mute_rules do |t| - t.foreign_key :users, on_delete: :cascade + t.remove_foreign_key :users end end end diff --git a/db/schema.rb b/db/schema.rb index 1873247f..dbed8eb9 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -324,8 +324,5 @@ ActiveRecord::Schema.define(version: 2022_07_14_212414) do t.index ["user_id"], name: "index_users_roles_on_user_id" end - add_foreign_key "anonymous_blocks", "questions", on_delete: :cascade - add_foreign_key "anonymous_blocks", "users", on_delete: :cascade - add_foreign_key "mute_rules", "users", on_delete: :cascade add_foreign_key "profiles", "users" end