diff options
Diffstat (limited to 'db')
-rw-r--r-- | db/migrate/20131218183023_delete_orphan_time_entries_custom_values.rb | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/db/migrate/20131218183023_delete_orphan_time_entries_custom_values.rb b/db/migrate/20131218183023_delete_orphan_time_entries_custom_values.rb new file mode 100644 index 000000000..f4e593559 --- /dev/null +++ b/db/migrate/20131218183023_delete_orphan_time_entries_custom_values.rb @@ -0,0 +1,9 @@ +class DeleteOrphanTimeEntriesCustomValues < ActiveRecord::Migration + 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 |