From 647f1f4def822d1d52f28b1a04d334792dbe3d81 Mon Sep 17 00:00:00 2001 From: kolaente Date: Wed, 17 Jun 2026 22:55:27 +0200 Subject: [PATCH] fix(migration): fail loudly if a deduplicated position pair has no row A pair returned by the GroupBy was just reported as duplicated, so a row must exist. Continuing on !has would let the delete loop drop every row for that pair without re-inserting one, silently losing positions. Abort the migration instead. --- pkg/migration/20260617153629.go | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/pkg/migration/20260617153629.go b/pkg/migration/20260617153629.go index f6e0cc9d7..d5ae3d772 100644 --- a/pkg/migration/20260617153629.go +++ b/pkg/migration/20260617153629.go @@ -17,6 +17,8 @@ package migration import ( + "fmt" + "src.techknowlogick.com/xormigrate" "xorm.io/xorm" "xorm.io/xorm/schemas" @@ -74,7 +76,12 @@ func init() { return err } if !has { - continue + // The pair was just reported as duplicated by the GroupBy above, + // so a row must exist. If it doesn't, fail instead of continuing — + // the delete loop below would otherwise drop every row for the pair + // without re-inserting one. + _ = s.Rollback() + return fmt.Errorf("no task_positions row found for task %d and project view %d while deduplicating positions", dup.TaskID, dup.ProjectViewID) } kept = append(kept, row) }