]> source.dussan.org Git - redmine.git/commitdiff
Add migration to delete orphaned time entry activities (#36416).
authorMarius Balteanu <marius.balteanu@zitec.com>
Thu, 24 Feb 2022 19:55:42 +0000 (19:55 +0000)
committerMarius Balteanu <marius.balteanu@zitec.com>
Thu, 24 Feb 2022 19:55:42 +0000 (19:55 +0000)
Patch by Holger Just.

git-svn-id: http://svn.redmine.org/redmine/trunk@21438 e93f8b46-1217-0410-a6f0-8f06a7374b81

db/migrate/20220224194639_delete_orphaned_time_entry_activities.rb [new file with mode: 0644]

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 (file)
index 0000000..51cf026
--- /dev/null
@@ -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