nullify invalid references beforehand
this can happen if containers are in the DB for a pipeline that was
destroyed, but the containers never expired
@@ -118,6 +118,15 @@ func CreateCaches(tx migration.LimitedTx) error {
return err
}
+ _, err = tx.Exec(`
+ UPDATE containers
+ SET build_id = NULL
+ WHERE build_id NOT IN (SELECT id FROM builds)
+ `)
+ if err != nil {
+ return err
+ }
+
_, err = tx.Exec(`
ALTER TABLE containers
ALTER COLUMN handle DROP NOT NULL,
