Skip to content

Commit f44b1d3

Browse files
authored
Remove routes without a node_id (#2386)
The routes table has a NOT NULL constraint on node_id. Fixes: #2376
1 parent 7ba6ad3 commit f44b1d3

File tree

2 files changed

+10
-0
lines changed

2 files changed

+10
-0
lines changed

CHANGELOG.md

+2
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@
1313

1414
- Fix issue where email and username being equal fails to match in Policy
1515
[#2388](https://github.com/juanfont/headscale/pull/2388)
16+
- Delete invalid routes before adding a NOT NULL constraint on node_id
17+
[#2386](https://github.com/juanfont/headscale/pull/2386)
1618

1719
## 0.24.1 (2025-01-23)
1820

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)