Update foreign keys instead of redefining them
This commit is contained in:
parent
f396167704
commit
3b98117dfa
|
@ -3,11 +3,8 @@
|
|||
class SetOnDeleteForAnonymousBlocks < ActiveRecord::Migration[6.1]
|
||||
def change
|
||||
change_table :anonymous_blocks do |t|
|
||||
t.remove_references :user
|
||||
t.references :user, null: false, foreign_key: true, on_delete: :cascade
|
||||
|
||||
t.remove_references :question
|
||||
t.references :question, null: true, foreign_key: true, on_delete: :null
|
||||
t.foreign_key :users, on_delete: :cascade
|
||||
t.foreign_key :questions, on_delete: :cascade
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -3,8 +3,7 @@
|
|||
class SetOnDeleteForMuteRules < ActiveRecord::Migration[6.1]
|
||||
def change
|
||||
change_table :mute_rules do |t|
|
||||
t.remove_references :user
|
||||
t.references :user, null: false, foreign_key: true, on_delete: :cascade
|
||||
t.foreign_key :users, on_delete: :cascade
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
10
db/schema.rb
10
db/schema.rb
|
@ -31,8 +31,8 @@ ActiveRecord::Schema.define(version: 2022_07_14_212414) do
|
|||
t.string "identifier"
|
||||
t.datetime "created_at", precision: 6, null: false
|
||||
t.datetime "updated_at", precision: 6, null: false
|
||||
t.bigint "user_id", null: false
|
||||
t.bigint "question_id"
|
||||
t.bigint "user_id"
|
||||
t.index ["identifier"], name: "index_anonymous_blocks_on_identifier"
|
||||
t.index ["question_id"], name: "index_anonymous_blocks_on_question_id"
|
||||
t.index ["user_id"], name: "index_anonymous_blocks_on_user_id"
|
||||
|
@ -125,7 +125,7 @@ ActiveRecord::Schema.define(version: 2022_07_14_212414) do
|
|||
t.string "muted_phrase"
|
||||
t.datetime "created_at", null: false
|
||||
t.datetime "updated_at", null: false
|
||||
t.bigint "user_id", null: false
|
||||
t.bigint "user_id"
|
||||
t.index ["user_id"], name: "index_mute_rules_on_user_id"
|
||||
end
|
||||
|
||||
|
@ -324,8 +324,8 @@ 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"
|
||||
add_foreign_key "anonymous_blocks", "users"
|
||||
add_foreign_key "mute_rules", "users"
|
||||
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
|
||||
|
|
Loading…
Reference in New Issue