Project

General

Profile

Defect #38966 » 20240523085253_remove_orphaned_custom_value_attachments.rb

Go MAEDA, 2024-05-23 11:15

 
1
class RemoveOrphanedCustomValueAttachments < ActiveRecord::Migration[7.1]
2
  def up
3
    Attachment.where(container_type: 'CustomValue')
4
              .where('NOT EXISTS (SELECT 1 FROM custom_values WHERE custom_values.id = attachments.container_id)')
5
              .destroy_all
6
  end
7

    
8
  def down
9
    # no-op
10
  end
11
end
(3-3/3)