mirror of
https://github.com/discourse/discourse.git
synced 2024-12-30 08:04:53 +08:00
f409e977a9
When EmbeddableHost is configured for a specific category and that category is deleted, then EmbeddableHost should be deleted as well. In addition, migration was added to fix existing data.
20 lines
473 B
Ruby
20 lines
473 B
Ruby
# frozen_string_literal: true
|
|
|
|
class DeleteMisconfiguredEmbeddableHosts < ActiveRecord::Migration[7.0]
|
|
def up
|
|
execute(<<~SQL)
|
|
DELETE FROM embeddable_hosts eh1
|
|
WHERE eh1.id IN (
|
|
SELECT eh2.id FROM embeddable_hosts eh2
|
|
LEFT JOIN categories ON categories.id = eh2.category_id
|
|
WHERE eh2.category_id IS NOT NULL
|
|
AND categories.id IS NULL
|
|
)
|
|
SQL
|
|
end
|
|
|
|
def down
|
|
raise ActiveRecord::IrreversibleMigration
|
|
end
|
|
end
|