mirror of
https://github.com/mastodon/mastodon.git
synced 2024-08-20 21:08:15 -07:00
Fix missing on_delete: :cascade for canonical_email_blocks foreign key (#16448)
This commit is contained in:
parent
7c27ccb8d8
commit
653c925beb
3 changed files with 16 additions and 3 deletions
|
@ -2,7 +2,7 @@ class CreateCanonicalEmailBlocks < ActiveRecord::Migration[6.1]
|
|||
def change
|
||||
create_table :canonical_email_blocks do |t|
|
||||
t.string :canonical_email_hash, null: false, default: '', index: { unique: true }
|
||||
t.belongs_to :reference_account, null: false, foreign_key: { on_cascade: :delete, to_table: 'accounts' }
|
||||
t.belongs_to :reference_account, null: false, foreign_key: { to_table: 'accounts' }
|
||||
|
||||
t.timestamps
|
||||
end
|
||||
|
|
|
@ -0,0 +1,13 @@
|
|||
class FixCanonicalEmailBlocksForeignKey < ActiveRecord::Migration[6.1]
|
||||
def up
|
||||
safety_assured do
|
||||
execute 'ALTER TABLE canonical_email_blocks DROP CONSTRAINT fk_rails_1ecb262096, ADD CONSTRAINT fk_rails_1ecb262096 FOREIGN KEY (reference_account_id) REFERENCES accounts(id) ON DELETE CASCADE;'
|
||||
end
|
||||
end
|
||||
|
||||
def down
|
||||
safety_assured do
|
||||
execute 'ALTER TABLE canonical_email_blocks DROP CONSTRAINT fk_rails_1ecb262096, ADD CONSTRAINT fk_rails_1ecb262096 FOREIGN KEY (reference_account_id) REFERENCES accounts(id);'
|
||||
end
|
||||
end
|
||||
end
|
|
@ -10,7 +10,7 @@
|
|||
#
|
||||
# It's strongly recommended that you check this file into your version control system.
|
||||
|
||||
ActiveRecord::Schema.define(version: 2021_06_09_202149) do
|
||||
ActiveRecord::Schema.define(version: 2021_06_30_000137) do
|
||||
|
||||
# These are extensions that must be enabled in order to support this database
|
||||
enable_extension "plpgsql"
|
||||
|
@ -997,7 +997,7 @@ ActiveRecord::Schema.define(version: 2021_06_09_202149) do
|
|||
add_foreign_key "blocks", "accounts", name: "fk_4269e03e65", on_delete: :cascade
|
||||
add_foreign_key "bookmarks", "accounts", on_delete: :cascade
|
||||
add_foreign_key "bookmarks", "statuses", on_delete: :cascade
|
||||
add_foreign_key "canonical_email_blocks", "accounts", column: "reference_account_id"
|
||||
add_foreign_key "canonical_email_blocks", "accounts", column: "reference_account_id", on_delete: :cascade
|
||||
add_foreign_key "conversation_mutes", "accounts", name: "fk_225b4212bb", on_delete: :cascade
|
||||
add_foreign_key "conversation_mutes", "conversations", on_delete: :cascade
|
||||
add_foreign_key "custom_filters", "accounts", on_delete: :cascade
|
||||
|
|
Loading…
Reference in a new issue