FIX: Destroy Drafts when increasing sequences (#27739)

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.
This commit is contained in:
Bianca Nenciu
2024-07-10 10:43:11 +03:00
committed by GitHub
parent acc8b46d51
commit 6591a0654b
3 changed files with 45 additions and 11 deletions

View File

@ -20,12 +20,7 @@ class DraftSequence < ActiveRecord::Base
RETURNING sequence
SQL
DB.exec(
"DELETE FROM drafts WHERE user_id = :user_id AND draft_key = :draft_key AND sequence < :sequence",
draft_key: key,
user_id: user_id,
sequence: sequence,
)
Draft.where(user_id: user_id).where(draft_key: key).where("sequence < ?", sequence).destroy_all
UserStat.update_draft_count(user_id)