mirror of
https://github.com/discourse/discourse.git
synced 2024-11-23 19:37:55 +08:00
20 lines
405 B
Ruby
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
|