Skip to content

OpenProject is the leading open source project management software for product, project and portfolio management. A powerful Jira alternative with agile planning, issue tracking, roadmaps, Gantt charts, time tracking, collaboration features, and more. Available on premises or in the cloud. ⭐ Star us on GitHub

Use the lock_optimistically method instead of using the locking_column because the activerecord-import gem respects it.

Dombi Attila5ebe4754d473
diff --git a/app/models/application_record.rb b/app/models/application_record.rb
index 8a8834495ca..98973520079 100644
--- a/app/models/application_record.rb
+++ b/app/models/application_record.rb
@@ -50,14 +50,10 @@ class ApplicationRecord < ActiveRecord::Base
end
def self.skip_optimistic_locking(&)
- # TODO: The activerecord-import gem does not respect the ActiveRecord::Base.lock_optimistically
- # flag, so a direct cleaning of the locking_column is necessary.
- # Once the gem is updated we can use the ActiveRecord::Base.lock_optimistically = false, instead of
- # removing the locking_column. See: https://github.com/zdennis/activerecord-import/pull/822
- original_locking_column = locking_column
- self.locking_column = nil
+ original_lock_optimistically = ActiveRecord::Base.lock_optimistically
+ ActiveRecord::Base.lock_optimistically = false
yield
ensure
- self.locking_column = original_locking_column
+ ActiveRecord::Base.lock_optimistically = original_lock_optimistically
end
end