relaxdiego/redmine_backlogs — Issue #362: Crash on migration to latest version
Author: pauleil
Created: 2011-11-28 20:42:21+00:00
State: open

Migration on Postgres results in:

Migrating redmine_backlogs...
== AddIndexOnIssuesPosition: migrating =======================================
-- add_index(:issues, :position)
-> 0.2176s
== AddIndexOnIssuesPosition: migrated (0.2183s) ==============================

== SumRemainingHours: migrating ==============================================
-- create_table(:backlogs_tmp_story_remaining_hours)
NOTICE: CREATE TABLE will create implicit sequence "backlogs_tmp_story_remaining_hours_id_seq" for serial column "backlogs_tmp_story_remaining_hours.id"
NOTICE: CREATE TABLE / PRIMARY KEY will create implicit index "backlogs_tmp_story_remaining_hours_pkey" for table "backlogs_tmp_story_remaining_hours"
-> 0.2031s
-- execute("insert into backlogs_tmp_story_remaining_hours (tmp_id, tmp_root_id, tmp_lft, tmp_rgt, tmp_remaining_hours)\n select id, root_id, lft, rgt, 0\n from issues\n where tracker_id in (1,2,3)")
-> 0.1067s
-- execute("update backlogs_tmp_story_remaining_hours\n set tmp_remaining_hours = (\n select sum(coalesce(remaining_hours, 0))\n from issues\n where root_id = tmp_root_id and lft > tmp_lft and rgt < tmp_rgt\n )")
rake aborted!
An error has occurred, this and all later migrations canceled:

PGError: ERROR: null value in column "tmp_remaining_hours" violates not-null constraint
: update backlogs_tmp_story_remaining_hours
set tmp_remaining_hours = (
select sum(coalesce(remaining_hours, 0))
from issues
where root_id = tmp_root_id and lft > tmp_lft and rgt < tmp_rgt
)