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

[#66093] Delete custom value errors to avoid foreign key violations

Tobias Dillmann69f1fad907ce
diff --git a/lib_static/plugins/acts_as_customizable/lib/acts_as_customizable.rb b/lib_static/plugins/acts_as_customizable/lib/acts_as_customizable.rb
index 05bbb564567..a360d297b38 100644
--- a/lib_static/plugins/acts_as_customizable/lib/acts_as_customizable.rb
+++ b/lib_static/plugins/acts_as_customizable/lib/acts_as_customizable.rb
@@ -200,6 +200,11 @@ module Redmine
def ensure_custom_values_complete
return unless custom_values.loaded? && (custom_values.any?(&:changed?) || custom_value_destroyed)
+ custom_values.select(&:marked_for_destruction?).each do |custom_value|
+ # Avoid foreign key constraint violations
+ custom_value.custom_value_errors.delete_all
+ end
+
self.custom_values = custom_field_values(all: true)
end