Skip to content

Commit

Permalink
Remove routes without a node_id
Browse files Browse the repository at this point in the history
The routes table has a NOT NULL constraint on node_id.

Fixes: #2376
  • Loading branch information
nblock committed Jan 30, 2025
1 parent 7ba6ad3 commit 984ee84
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@

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

## 0.24.1 (2025-01-23)

Expand Down
8 changes: 8 additions & 0 deletions hscontrol/db/db.go
Original file line number Diff line number Diff line change
Expand Up @@ -565,6 +565,14 @@ COMMIT;
}
}

// Remove any invalid routes without a node_id.
if tx.Migrator().HasTable(&types.Route{}) {
err := tx.Exec("delete from routes where node_id is null").Error
if err != nil {
return err
}
}

err := tx.AutoMigrate(&types.Route{})
if err != nil {
return err
Expand Down

0 comments on commit 984ee84

Please sign in to comment.