Files
discourse/db/migrate/20240506035024_clear_orphaned_draft_upload_references.rb
Roman Rizzi 42fb6c9822 DEV: Promote historic post_deploy migrations (#30959)
This commit promotes all post_deploy migrations which existed in
Discourse v3.3.0 (timestamp <= 20240717053710)
2025-01-24 10:57:12 -03:00

21 lines
437 B
Ruby

# frozen_string_literal: true
class ClearOrphanedDraftUploadReferences < 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