Skip to content

Commit

Permalink
Merge pull request #16820 from opf/fix/make-progress-migration-work-b…
Browse files Browse the repository at this point in the history
…efore-14-0

[57990] Make migration work with database from before 14.0 version
  • Loading branch information
cbliard authored Sep 26, 2024
2 parents 458e1a9 + 775a526 commit 2e092c2
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 1 deletion.
27 changes: 27 additions & 0 deletions app/workers/work_packages/progress/sql_commands_for_migration.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion lib/open_project/static/links.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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: {
Expand Down

0 comments on commit 2e092c2

Please sign in to comment.