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.
This commit is contained in:
kolaente 2026-06-17 22:55:27 +02:00 committed by kolaente
parent a61e594952
commit 647f1f4def
1 changed files with 8 additions and 1 deletions

View File

@ -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)
}