mirror of https://github.com/mastodon/mastodon
Add missing `on_delete: :cascade` foreign keys option (#33175)
This commit is contained in:
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
|
|
@ -10,7 +10,7 @@
|
||||||
#
|
#
|
||||||
# It's strongly recommended that you check this file into your version control system.
|
# It's strongly recommended that you check this file into your version control system.
|
||||||
|
|
||||||
ActiveRecord::Schema[7.2].define(version: 2024_12_05_135925) do
|
ActiveRecord::Schema[7.2].define(version: 2024_12_05_163118) do
|
||||||
# These are extensions that must be enabled in order to support this database
|
# These are extensions that must be enabled in order to support this database
|
||||||
enable_extension "plpgsql"
|
enable_extension "plpgsql"
|
||||||
|
|
||||||
|
@ -1235,8 +1235,8 @@ ActiveRecord::Schema[7.2].define(version: 2024_12_05_135925) do
|
||||||
add_foreign_key "account_domain_blocks", "accounts", name: "fk_206c6029bd", on_delete: :cascade
|
add_foreign_key "account_domain_blocks", "accounts", name: "fk_206c6029bd", on_delete: :cascade
|
||||||
add_foreign_key "account_migrations", "accounts", column: "target_account_id", on_delete: :nullify
|
add_foreign_key "account_migrations", "accounts", column: "target_account_id", on_delete: :nullify
|
||||||
add_foreign_key "account_migrations", "accounts", on_delete: :cascade
|
add_foreign_key "account_migrations", "accounts", on_delete: :cascade
|
||||||
add_foreign_key "account_moderation_notes", "accounts"
|
add_foreign_key "account_moderation_notes", "accounts", column: "target_account_id", on_delete: :cascade
|
||||||
add_foreign_key "account_moderation_notes", "accounts", column: "target_account_id"
|
add_foreign_key "account_moderation_notes", "accounts", on_delete: :cascade
|
||||||
add_foreign_key "account_notes", "accounts", column: "target_account_id", on_delete: :cascade
|
add_foreign_key "account_notes", "accounts", column: "target_account_id", on_delete: :cascade
|
||||||
add_foreign_key "account_notes", "accounts", on_delete: :cascade
|
add_foreign_key "account_notes", "accounts", on_delete: :cascade
|
||||||
add_foreign_key "account_pins", "accounts", column: "target_account_id", on_delete: :cascade
|
add_foreign_key "account_pins", "accounts", column: "target_account_id", on_delete: :cascade
|
||||||
|
@ -1360,7 +1360,7 @@ ActiveRecord::Schema[7.2].define(version: 2024_12_05_135925) do
|
||||||
add_foreign_key "web_push_subscriptions", "oauth_access_tokens", column: "access_token_id", on_delete: :cascade
|
add_foreign_key "web_push_subscriptions", "oauth_access_tokens", column: "access_token_id", on_delete: :cascade
|
||||||
add_foreign_key "web_push_subscriptions", "users", on_delete: :cascade
|
add_foreign_key "web_push_subscriptions", "users", on_delete: :cascade
|
||||||
add_foreign_key "web_settings", "users", name: "fk_11910667b2", on_delete: :cascade
|
add_foreign_key "web_settings", "users", name: "fk_11910667b2", on_delete: :cascade
|
||||||
add_foreign_key "webauthn_credentials", "users"
|
add_foreign_key "webauthn_credentials", "users", on_delete: :cascade
|
||||||
|
|
||||||
create_view "instances", materialized: true, sql_definition: <<-SQL
|
create_view "instances", materialized: true, sql_definition: <<-SQL
|
||||||
WITH domain_counts(domain, accounts_count) AS (
|
WITH domain_counts(domain, accounts_count) AS (
|
||||||
|
|
Loading…
Reference in New Issue