mirror of https://github.com/mastodon/mastodon
Add missing `on_delete: :cascade` foreign keys option (#33175)
parent
635da00cfa
commit
a1143c522b
@ -0,0 +1,28 @@
|
|||||||
|
# frozen_string_literal: true
|
||||||
|
|
||||||
|
class AddMissingDeleteCascadeWebauthnCredentials < ActiveRecord::Migration[7.2]
|
||||||
|
def up
|
||||||
|
safety_assured do
|
||||||
|
execute <<~SQL.squish
|
||||||
|
ALTER TABLE webauthn_credentials
|
||||||
|
DROP CONSTRAINT fk_rails_a4355aef77,
|
||||||
|
ADD CONSTRAINT fk_rails_a4355aef77
|
||||||
|
FOREIGN KEY (user_id)
|
||||||
|
REFERENCES users(id)
|
||||||
|
ON DELETE CASCADE
|
||||||
|
SQL
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
def down
|
||||||
|
safety_assured do
|
||||||
|
execute <<~SQL.squish
|
||||||
|
ALTER TABLE webauthn_credentials
|
||||||
|
DROP CONSTRAINT fk_rails_a4355aef77,
|
||||||
|
ADD CONSTRAINT fk_rails_a4355aef77
|
||||||
|
FOREIGN KEY (user_id)
|
||||||
|
REFERENCES users(id)
|
||||||
|
SQL
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
@ -0,0 +1,45 @@
|
|||||||
|
# frozen_string_literal: true
|
||||||
|
|
||||||
|
class AddMissingDeleteCascadeAccountModerationNotes < ActiveRecord::Migration[7.2]
|
||||||
|
def up
|
||||||
|
safety_assured do
|
||||||
|
execute <<~SQL.squish
|
||||||
|
ALTER TABLE account_moderation_notes
|
||||||
|
DROP CONSTRAINT fk_rails_3f8b75089b,
|
||||||
|
ADD CONSTRAINT fk_rails_3f8b75089b
|
||||||
|
FOREIGN KEY (account_id)
|
||||||
|
REFERENCES accounts(id)
|
||||||
|
ON DELETE CASCADE
|
||||||
|
SQL
|
||||||
|
|
||||||
|
execute <<~SQL.squish
|
||||||
|
ALTER TABLE account_moderation_notes
|
||||||
|
DROP CONSTRAINT fk_rails_dd62ed5ac3,
|
||||||
|
ADD CONSTRAINT fk_rails_dd62ed5ac3
|
||||||
|
FOREIGN KEY (target_account_id)
|
||||||
|
REFERENCES accounts(id)
|
||||||
|
ON DELETE CASCADE
|
||||||
|
SQL
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
def down
|
||||||
|
safety_assured do
|
||||||
|
execute <<~SQL.squish
|
||||||
|
ALTER TABLE account_moderation_notes
|
||||||
|
DROP CONSTRAINT fk_rails_3f8b75089b,
|
||||||
|
ADD CONSTRAINT fk_rails_3f8b75089b
|
||||||
|
FOREIGN KEY (account_id)
|
||||||
|
REFERENCES accounts(id)
|
||||||
|
SQL
|
||||||
|
|
||||||
|
execute <<~SQL.squish
|
||||||
|
ALTER TABLE account_moderation_notes
|
||||||
|
DROP CONSTRAINT fk_rails_dd62ed5ac3,
|
||||||
|
ADD CONSTRAINT fk_rails_dd62ed5ac3
|
||||||
|
FOREIGN KEY (target_account_id)
|
||||||
|
REFERENCES accounts(id)
|
||||||
|
SQL
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
Loading…
Reference in New Issue