20220307094650_fix_featured_tags_constraints.rb 521 B

1234567891011121314151617
  1. class FixFeaturedTagsConstraints < ActiveRecord::Migration[6.1]
  2. def up
  3. safety_assured do
  4. execute 'DELETE FROM featured_tags WHERE tag_id IS NULL'
  5. change_column_null :featured_tags, :tag_id, false
  6. execute 'DELETE FROM featured_tags WHERE account_id IS NULL'
  7. change_column_null :featured_tags, :account_id, false
  8. end
  9. end
  10. def down
  11. safety_assured do
  12. change_column_null :featured_tags, :tag_id, true
  13. change_column_null :featured_tags, :account_id, true
  14. end
  15. end
  16. end