0
0
Fork 0
mirror of https://github.com/discourse/discourse.git synced 2026-08-09 20:33:03 +08:00
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

20 lines
437 B
Ruby
Vendored

# 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