discourse/db/migrate/20230728055813_delete_orpha...

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

21 lines
438 B
Ruby
Raw Normal View History

# frozen_string_literal: true
class DeleteOrphanedDraftUploadReferences < ActiveRecord::Migration[7.0]
def up
execute <<~SQL
DELETE
FROM
"upload_references"
WHERE
"upload_references"."target_type" = 'Draft' AND
"upload_references"."target_id" NOT IN (
SELECT "drafts"."id" FROM "drafts"
)
SQL
end
def down
raise ActiveRecord::IrreversibleMigration
end
end