Files
Redmine/db/migrate/20241022095140_remove_orphaned_custom_value_attachments.rb
Go MAEDA 55c7a3177f Fix missing deletion of custom field attachments upon issue deletion (#38966).
Patch by Takenori TAKAKI (user:takenory).


git-svn-id: https://svn.redmine.org/redmine/trunk@23161 e93f8b46-1217-0410-a6f0-8f06a7374b81
2024-10-26 02:14:09 +00:00

12 lines
317 B
Ruby

class RemoveOrphanedCustomValueAttachments < ActiveRecord::Migration[7.2]
def up
Attachment.where(container_type: 'CustomValue')
.where('NOT EXISTS (SELECT 1 FROM custom_values WHERE custom_values.id = attachments.container_id)')
.destroy_all
end
def down
# no-op
end
end