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

[#44347] Milestones existing before 12.3 will have nil for duration

Dombi Attilaf77410cba8c9
diff --git a/db/migrate/20220930133418_set_duration_for_milestone_work_packages.rb b/db/migrate/20220930133418_set_duration_for_milestone_work_packages.rb
new file mode 100644
index 00000000000..261fc144ad2
--- /dev/null
+++ b/db/migrate/20220930133418_set_duration_for_milestone_work_packages.rb
@@ -0,0 +1,24 @@
+class SetDurationForMilestoneWorkPackages < 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 = 1
+ WHERE
+ EXISTS (
+ SELECT * FROM types type
+ WHERE
+ type.is_milestone = TRUE AND
+ type.id = #{table}.type_id
+ )
+ SQL
+ end
+end