From 381e2f4b09924a59f2961b024d71988e7a8f4684 Mon Sep 17 00:00:00 2001 From: Christophe Bliard Date: Thu, 26 Sep 2024 11:42:16 +0200 Subject: [PATCH 1/2] [57990] Make migration work with database from before 14.0 version https://community.openproject.org/wp/57990 The code to create the temporary table in common between the migration and the job to update status and % complete values. It has recently changed to get the `excluded_from_totals` value from the `statuses` table, but this field has been created in 14.2, and does not exist yet in 14.0 when this migration is run. This commit adds the previous version of the code to create the temporary table, that does not require the `excluded_from_totals` field. It also avoids creating the depths table which is not necessary in this case. --- .../progress/sql_commands_for_migration.rb | 27 +++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/app/workers/work_packages/progress/sql_commands_for_migration.rb b/app/workers/work_packages/progress/sql_commands_for_migration.rb index e62d424456a6..6d4dca24297d 100644 --- a/app/workers/work_packages/progress/sql_commands_for_migration.rb +++ b/app/workers/work_packages/progress/sql_commands_for_migration.rb @@ -32,6 +32,33 @@ # migrations, as some methods in `WorkPackages::Progress::SqlCommands` rely on # fields that may not exist yet. module WorkPackages::Progress::SqlCommandsForMigration + def with_temporary_progress_table + WorkPackage.transaction do + create_temporary_progress_table + yield + ensure + drop_temporary_progress_table + end + end + + # Create temporary tables with the columns that existed in version 14.0 + # (version where the migration is run). + def create_temporary_progress_table + execute(<<~SQL.squish) + CREATE UNLOGGED TABLE temp_wp_progress_values + AS SELECT + id, + status_id, + estimated_hours, + remaining_hours, + done_ratio, + NULL::double precision AS total_work, + NULL::double precision AS total_remaining_work, + NULL::integer AS total_p_complete + FROM work_packages + SQL + end + # Computes total work, total remaining work and total % complete for all work # packages having children. def update_totals From 775a526181c764da21593796ef8d6079d2b7674d Mon Sep 17 00:00:00 2001 From: Christophe Bliard Date: Thu, 26 Sep 2024 12:06:36 +0200 Subject: [PATCH 2/2] [57990] Update link to blog article for progress migration --- lib/open_project/static/links.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/open_project/static/links.rb b/lib/open_project/static/links.rb index 97bf710de570..a39d02436a6a 100644 --- a/lib/open_project/static/links.rb +++ b/lib/open_project/static/links.rb @@ -170,7 +170,7 @@ def static_links label: "homescreen.links.blog" }, blog_article_progress_changes: { - href: "https://www.openproject.org/blog/changes-progress-work-estimates/", + href: "https://www.openproject.org/blog/updates-to-progress-tracking-in-14-4-based-on-user-feedback/", label: "Significant changes to progress and work estimates" }, release_notes: {