Skip to content

Commit

Permalink
Fixes tests after merge
Browse files Browse the repository at this point in the history
  • Loading branch information
hopleus committed Dec 2, 2024
1 parent 33337cf commit d49b88b
Showing 1 changed file with 0 additions and 42 deletions.
42 changes: 0 additions & 42 deletions hscontrol/db/db.go
Original file line number Diff line number Diff line change
Expand Up @@ -492,48 +492,6 @@ func NewHeadscaleDatabase(
},
Rollback: func(db *gorm.DB) error { return nil },
},
{
ID: "202410071005",
Migrate: func(db *gorm.DB) error {
err = db.AutoMigrate(&types.PreAuthKey{})
if err != nil {
return err
}

err = db.AutoMigrate(&types.Node{})
if err != nil {
return err
}

if db.Migrator().HasColumn(&types.Node{}, "approved") {
nodes := types.Nodes{}
if err := db.Find(&nodes).Error; err != nil {
log.Error().Err(err).Msg("Error accessing db")
}

for item, node := range nodes {
if !node.IsApproved() {
err = db.Model(nodes[item]).Updates(types.Node{
Approved: true,
}).Error
if err != nil {
log.Error().
Caller().
Str("hostname", node.Hostname).
Bool("approved", node.IsApproved()).
Err(err).
Msg("Failed to add approval option to existing nodes during database migration")
}
}
}

return nil
}

return errNoNodeApprovedColumnInDatabase
},
Rollback: func(db *gorm.DB) error { return nil },
},
{
// The unique constraint of Name has been dropped
// in favour of a unique together of name and
Expand Down

0 comments on commit d49b88b

Please sign in to comment.