From 3627a29fa6ddc97b51dcec5517da5531fc56d368 Mon Sep 17 00:00:00 2001 From: Marius Balteanu Date: Thu, 24 Feb 2022 19:55:42 +0000 Subject: [PATCH] Add migration to delete orphaned time entry activities (#36416). Patch by Holger Just. git-svn-id: http://svn.redmine.org/redmine/trunk@21438 e93f8b46-1217-0410-a6f0-8f06a7374b81 --- ...220224194639_delete_orphaned_time_entry_activities.rb | 9 +++++++++ 1 file changed, 9 insertions(+) create mode 100644 db/migrate/20220224194639_delete_orphaned_time_entry_activities.rb diff --git a/db/migrate/20220224194639_delete_orphaned_time_entry_activities.rb b/db/migrate/20220224194639_delete_orphaned_time_entry_activities.rb new file mode 100644 index 000000000..51cf0265b --- /dev/null +++ b/db/migrate/20220224194639_delete_orphaned_time_entry_activities.rb @@ -0,0 +1,9 @@ +class DeleteOrphanedTimeEntryActivities < ActiveRecord::Migration[6.1] + def self.up + TimeEntryActivity.left_outer_joins(:project).where(projects:{id: nil}).where.not(project_id: nil).delete_all + end + + def self.down + # no-op + end +end -- 2.39.5