Skip to content

Commit

Permalink
remove last_successful_update, ignore error
Browse files Browse the repository at this point in the history
most of the time we dont even check this error and checking
the string for particular errors is very flake as different
databases (sqlite and psql) use different error messages, and
some users might have it in other languages.

Fixes #1956

Signed-off-by: Kristoffer Dalby <kristoffer@tailscale.com>
  • Loading branch information
kradalby committed May 27, 2024
1 parent c8ebbed commit 7d525b2
Showing 1 changed file with 2 additions and 9 deletions.
11 changes: 2 additions & 9 deletions hscontrol/db/db.go
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ func NewHeadscaleDatabase(
RenameColumn(&types.Node{}, "nickname", "given_name")

dbConn.Model(&types.Node{}).Where("auth_key_id = ?", 0).Update("auth_key_id", nil)
// If the Node table has a column for registered,
// If the Node table has a column for registered,
// find all occourences of "false" and drop them. Then
// remove the column.
if tx.Migrator().HasColumn(&types.Node{}, "registered") {
Expand Down Expand Up @@ -319,14 +319,7 @@ func NewHeadscaleDatabase(
// no longer used.
ID: "202402151347",
Migrate: func(tx *gorm.DB) error {
err := tx.Migrator().DropColumn(&types.Node{}, "last_successful_update")
if err != nil && strings.Contains(err.Error(), `of relation "nodes" does not exist`) {
return nil
} else {
return err
}

return err
_ = tx.Migrator().DropColumn(&types.Node{}, "last_successful_update")
},
Rollback: func(tx *gorm.DB) error {
return nil
Expand Down

0 comments on commit 7d525b2

Please sign in to comment.