summaryrefslogtreecommitdiffstats
path: root/db/migrate/20131218183023_delete_orphan_time_entries_custom_values.rb
blob: e9d902d2f053c669a13de532aae0d3c563fd07a7 (plain)
1
2
3
4
5
6
7
8
9
class DeleteOrphanTimeEntriesCustomValues < ActiveRecord::Migration[4.2]
  def up
    CustomValue.where("customized_type = ? AND NOT EXISTS (SELECT 1 FROM #{TimeEntry.table_name} t WHERE t.id = customized_id)", "TimeEntry").delete_all
  end

  def down
    # nop
  end
end