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:
parent
a61e594952
commit
647f1f4def
|
|
@ -17,6 +17,8 @@
|
||||||
package migration
|
package migration
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"fmt"
|
||||||
|
|
||||||
"src.techknowlogick.com/xormigrate"
|
"src.techknowlogick.com/xormigrate"
|
||||||
"xorm.io/xorm"
|
"xorm.io/xorm"
|
||||||
"xorm.io/xorm/schemas"
|
"xorm.io/xorm/schemas"
|
||||||
|
|
@ -74,7 +76,12 @@ func init() {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
if !has {
|
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)
|
kept = append(kept, row)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue