Skip to content

Commit 341a3d3

Browse files
nblockkradalby
authored andcommitted
Remove routes without a node_id (#2386)
The routes table has a NOT NULL constraint on node_id. Fixes: #2376
1 parent 46b8226 commit 341a3d3

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
@@ -7,6 +7,8 @@
77

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

1113
## 0.24.1 (2025-01-23)
1214

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)