mirror of
https://github.com/discourse/discourse.git
synced 2024-12-12 15:33:55 +08:00
20 lines
387 B
Ruby
20 lines
387 B
Ruby
|
# frozen_string_literal: true
|
||
|
|
||
|
class DeleteOrphanPostActions < ActiveRecord::Migration[6.0]
|
||
|
def up
|
||
|
sql = <<~SQL
|
||
|
DELETE FROM post_actions
|
||
|
USING post_actions pa
|
||
|
LEFT JOIN posts ON posts.id = pa.post_id
|
||
|
WHERE posts.id IS NULL
|
||
|
AND post_actions.id = pa.id
|
||
|
SQL
|
||
|
|
||
|
execute(sql)
|
||
|
end
|
||
|
|
||
|
def down
|
||
|
raise ActiveRecord::IrreversibleMigration
|
||
|
end
|
||
|
end
|