mirror of
https://github.com/discourse/discourse.git
synced 2025-06-01 03:35:15 +08:00
FIX: destroy CategoryGroup when Category or Group is destroyed
This commit is contained in:
@ -0,0 +1,13 @@
|
||||
class RemoveCategoryGroupsOrphanedByRemovingCategoryOrGroup < ActiveRecord::Migration
|
||||
def up
|
||||
execute "DELETE FROM category_groups
|
||||
WHERE group_id NOT IN (
|
||||
SELECT groups.id FROM groups)
|
||||
OR category_id NOT IN (
|
||||
SELECT categories.id FROM categories)"
|
||||
end
|
||||
|
||||
def down
|
||||
raise ActiveRecord::IrreversibleMigration
|
||||
end
|
||||
end
|
Reference in New Issue
Block a user