diff options
author | Eugen Rochko <eugen@zeonfederated.com> | 2022-03-09 08:51:12 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-03-09 08:51:12 +0100 |
commit | 318d34d528d8d4f9165bf9c1f873da68aadb90a2 (patch) | |
tree | 4fcbe1c0678fc37144635a68fae0d70f47d84f0b /db/migrate | |
parent | c0327ff31f839e1beae59486bf92d7e1c4689b06 (diff) |
Fix data integrity of featured tags (#17712)
Diffstat (limited to 'db/migrate')
-rw-r--r-- | db/migrate/20220307094650_fix_featured_tags_constraints.rb | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/db/migrate/20220307094650_fix_featured_tags_constraints.rb b/db/migrate/20220307094650_fix_featured_tags_constraints.rb new file mode 100644 index 000000000..bad1c90d4 --- /dev/null +++ b/db/migrate/20220307094650_fix_featured_tags_constraints.rb @@ -0,0 +1,17 @@ +class FixFeaturedTagsConstraints < ActiveRecord::Migration[6.1] + def up + safety_assured do + execute 'DELETE FROM featured_tags WHERE tag_id IS NULL' + change_column_null :featured_tags, :tag_id, false + execute 'DELETE FROM featured_tags WHERE account_id IS NULL' + change_column_null :featured_tags, :account_id, false + end + end + + def down + safety_assured do + change_column_null :featured_tags, :tag_id, true + change_column_null :featured_tags, :account_id, true + end + end +end |