DEV: Move tag_group cleanup from post_migrate -> migrate (#16434)

There is no need to wait until after the deploy for this cleanup. In fact, running it later will mean there could be a window of a few minutes during which the site is broken.

The only requirement is that it runs after the broken `20220401130745_create_category_required_tag_groups` migration.

Followup to 39a6de3d73
This commit is contained in:
David Taylor
2022-04-11 13:28:24 +01:00
committed by GitHub
parent 7b1686ad7d
commit 1e436f242e

View File

@@ -1,19 +0,0 @@
# frozen_string_literal: true
class RemoveCategoryRequiredTagGroupsWithoutTagGroups < ActiveRecord::Migration[6.1]
def up
execute <<~SQL
DELETE FROM category_required_tag_groups
WHERE id IN (
SELECT crtg.id
FROM category_required_tag_groups crtg
LEFT OUTER JOIN tag_groups tg ON crtg.tag_group_id = tg.id
WHERE tg.id IS NULL
)
SQL
end
def down
raise ActiveRecord::IrreversibleMigration
end
end