Skip to content

Commit 82b69ed

Browse files
committed
Remove routes without a node_id
The routes table has a NOT NULL constraint on node_id. Fixes: #2376
1 parent 2c279e0 commit 82b69ed

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

hscontrol/db/db.go

+8
Original file line numberDiff line numberDiff line change
@@ -565,6 +565,14 @@ COMMIT;
565565
}
566566
}
567567

568+
// Remove any invalid routes without a node_id.
569+
if tx.Migrator().HasTable(&types.Route{}) {
570+
err := tx.Exec("delete from routes where node_id is null").Error
571+
if err != nil {
572+
return err
573+
}
574+
}
575+
568576
err := tx.AutoMigrate(&types.Route{})
569577
if err != nil {
570578
return err

0 commit comments

Comments
 (0)