20241007071624_fix_notification_permission_foreign_keys.rb 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. # frozen_string_literal: true
  2. class FixNotificationPermissionForeignKeys < ActiveRecord::Migration[7.1]
  3. def up
  4. safety_assured do
  5. execute <<~SQL.squish
  6. ALTER TABLE notification_permissions
  7. DROP CONSTRAINT fk_rails_7c0bed08df,
  8. ADD CONSTRAINT fk_rails_7c0bed08df
  9. FOREIGN KEY (account_id)
  10. REFERENCES accounts(id)
  11. ON DELETE CASCADE,
  12. DROP CONSTRAINT fk_rails_e3e0aaad70,
  13. ADD CONSTRAINT fk_rails_e3e0aaad70
  14. FOREIGN KEY (from_account_id)
  15. REFERENCES accounts(id)
  16. ON DELETE CASCADE
  17. SQL
  18. end
  19. end
  20. def down
  21. safety_assured do
  22. execute <<~SQL.squish
  23. ALTER TABLE notification_permissions
  24. DROP CONSTRAINT fk_rails_7c0bed08df,
  25. ADD CONSTRAINT fk_rails_7c0bed08df
  26. FOREIGN KEY (account_id)
  27. REFERENCES accounts(id),
  28. DROP CONSTRAINT fk_rails_e3e0aaad70,
  29. ADD CONSTRAINT fk_rails_e3e0aaad70
  30. FOREIGN KEY (from_account_id)
  31. REFERENCES accounts(id)
  32. SQL
  33. end
  34. end
  35. end