mirror of
https://gh.wpcy.net/https://github.com/discourse/discourse.git
synced 2026-05-04 05:09:20 +08:00
Drafts used to be deleted instead of being destroyed. The callbacks that
clean up the upload references were not being called. As a result, the
upload references were not cleaned up and uploads were not deleted
either. This has been partially fixed in 9655bf3e.
20 lines
438 B
Ruby
20 lines
438 B
Ruby
# frozen_string_literal: true
|
|
|
|
class ClearOrphanedDraftUploadReferences2 < ActiveRecord::Migration[7.1]
|
|
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
|