discourse/db/migrate/20230111223803_delete_misconfigured_embeddable_hosts.rb

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

20 lines
473 B
Ruby
Raw Normal View History

# 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