20240510192043_fix_notification_policies_foreign_key.rb 719 B

12345678910111213141516171819202122232425262728
  1. # frozen_string_literal: true
  2. class FixNotificationPoliciesForeignKey < ActiveRecord::Migration[7.1]
  3. def up
  4. safety_assured do
  5. execute <<~SQL.squish
  6. ALTER TABLE notification_policies
  7. DROP CONSTRAINT fk_rails_506d62f0da,
  8. ADD CONSTRAINT fk_rails_506d62f0da
  9. FOREIGN KEY (account_id)
  10. REFERENCES accounts(id)
  11. ON DELETE CASCADE
  12. SQL
  13. end
  14. end
  15. def down
  16. safety_assured do
  17. execute <<~SQL.squish
  18. ALTER TABLE notification_policies
  19. DROP CONSTRAINT fk_rails_506d62f0da,
  20. ADD CONSTRAINT fk_rails_506d62f0da
  21. FOREIGN KEY (account_id)
  22. REFERENCES accounts(id)
  23. SQL
  24. end
  25. end
  26. end