diff --git a/db/migrate/20190722082648_add_derived_estimated_hours_to_work_packages.rb b/db/migrate/20190722082648_add_derived_estimated_hours_to_work_packages.rb index 679014f90a..9d89bc784a 100644 --- a/db/migrate/20190722082648_add_derived_estimated_hours_to_work_packages.rb +++ b/db/migrate/20190722082648_add_derived_estimated_hours_to_work_packages.rb @@ -45,7 +45,7 @@ class AddDerivedEstimatedHoursToWorkPackages < ActiveRecord::Migration[5.2] create_customizable_journals last_id: last_id create_attachable_journals last_id: last_id - work_packages.each(&:touch) # invalidate cache + touch_work_packages work_packages # to invalidate cache end ## @@ -164,4 +164,12 @@ class AddDerivedEstimatedHoursToWorkPackages < ActiveRecord::Migration[5.2] WHERE #{journals}.id > #{last_id} -- make sure to only create entries for the newly created journals ") end + + def touch_work_packages(work_packages) + where = work_packages.arel.where_sql + + WorkPackage.connection.execute(" + UPDATE work_packages SET updated_at = NOW(), lock_version = lock_version + 1 #{where} + ") + end end