summaryrefslogtreecommitdiffstats
path: root/db
diff options
context:
space:
mode:
authorJean-Philippe Lang <jp_lang@yahoo.fr>2013-12-18 18:39:09 +0000
committerJean-Philippe Lang <jp_lang@yahoo.fr>2013-12-18 18:39:09 +0000
commit5c5ba0c61af44bdbd8931c131192963179cca9ac (patch)
treed950222bd2a006e1b1ce1d14b31e607f95240d6e /db
parentd4297ca3ff309a63737e2d12adb4ea1ec0085828 (diff)
downloadredmine-5c5ba0c61af44bdbd8931c131192963179cca9ac.tar.gz
redmine-5c5ba0c61af44bdbd8931c131192963179cca9ac.zip
Fixed that time entries custom values are not deleted when deleting a project or an issue (#15709).
git-svn-id: http://svn.redmine.org/redmine/trunk@12421 e93f8b46-1217-0410-a6f0-8f06a7374b81
Diffstat (limited to 'db')
-rw-r--r--db/migrate/20131218183023_delete_orphan_time_entries_custom_values.rb9
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