discourse/db/migrate/20210324043327_delete_orphan_post_revisions.rb
David Taylor f3aab19829
DEV: Promote historic post_deploy migrations (#16288)
This commit promotes all post_deploy migrations which existed in Discourse v2.7.13 (timestamp <= 20210328233843)

This reduces the likelihood of issues relating to migration run order

Also fixes a couple of typos in `script/promote_migrations`
2022-03-25 15:48:20 +00:00

20 lines
405 B
Ruby

# frozen_string_literal: true
class DeleteOrphanPostRevisions < ActiveRecord::Migration[6.0]
def up
sql = <<~SQL
DELETE FROM post_revisions
USING post_revisions pr
LEFT JOIN posts ON posts.id = pr.post_id
WHERE posts.id IS NULL
AND post_revisions.id = pr.id
SQL
execute(sql)
end
def down
raise ActiveRecord::IrreversibleMigration
end
end