Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add missing on_delete: :cascade on notification_policies #30251

Merged
merged 1 commit into from
May 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
28 changes: 28 additions & 0 deletions db/migrate/20240510192043_fix_notification_policies_foreign_key.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# frozen_string_literal: true

class FixNotificationPoliciesForeignKey < ActiveRecord::Migration[7.1]
def up
safety_assured do
execute <<~SQL.squish
ALTER TABLE notification_policies
DROP CONSTRAINT fk_rails_506d62f0da,
ADD CONSTRAINT fk_rails_506d62f0da
FOREIGN KEY (account_id)
REFERENCES accounts(id)
ON DELETE CASCADE
SQL
end
end

def down
safety_assured do
execute <<~SQL.squish
ALTER TABLE notification_policies
DROP CONSTRAINT fk_rails_506d62f0da,
ADD CONSTRAINT fk_rails_506d62f0da
FOREIGN KEY (account_id)
REFERENCES accounts(id)
SQL
end
end
end
4 changes: 2 additions & 2 deletions db/schema.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
#
# It's strongly recommended that you check this file into your version control system.

ActiveRecord::Schema[7.1].define(version: 2024_03_22_161611) do
ActiveRecord::Schema[7.1].define(version: 2024_05_10_192043) do
# These are extensions that must be enabled in order to support this database
enable_extension "plpgsql"

Expand Down Expand Up @@ -1335,7 +1335,7 @@
add_foreign_key "mutes", "accounts", name: "fk_b8d8daf315", on_delete: :cascade
add_foreign_key "notification_permissions", "accounts"
add_foreign_key "notification_permissions", "accounts", column: "from_account_id"
add_foreign_key "notification_policies", "accounts"
add_foreign_key "notification_policies", "accounts", on_delete: :cascade
add_foreign_key "notification_requests", "accounts", column: "from_account_id", on_delete: :cascade
add_foreign_key "notification_requests", "accounts", on_delete: :cascade
add_foreign_key "notification_requests", "statuses", column: "last_status_id", on_delete: :nullify
Expand Down