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

Reset the default values of work package and work package journal duration

Dombi Attila64cfcaaefbd9
diff --git a/db/migrate/20220620132922_change_duration_default_value.rb b/db/migrate/20220620132922_change_duration_default_value.rb
new file mode 100644
index 00000000000..5be582891fb
--- /dev/null
+++ b/db/migrate/20220620132922_change_duration_default_value.rb
@@ -0,0 +1,22 @@
+class ChangeDurationDefaultValue < ActiveRecord::Migration[7.0]
+ def up
+ set_duration(:work_packages)
+ set_duration(:work_package_journals)
+ end
+
+ private
+
+ def set_duration(table)
+ execute <<~SQL.squish
+ UPDATE
+ #{table}
+ SET
+ duration = CASE
+ WHEN start_date IS NULL OR due_date IS NULL
+ THEN NULL
+ ELSE
+ due_date - start_date + 1
+ END
+ SQL
+ end
+end