Fix crash when a prefix family was empty

This commit is contained in:
Juan Font 2024-04-17 13:23:29 +00:00
parent 40953727cf
commit dd0cc74688
1 changed files with 10 additions and 6 deletions

View File

@ -377,16 +377,20 @@ func NewHeadscaleDatabase(
}
}
if v4 != nil {
err = tx.Model(&types.Node{}).Where("id = ?", node.ID).Update("ipv4", v4.String()).Error
if err != nil {
return fmt.Errorf("saving ip addresses to new columns: %w", err)
}
}
if v6 != nil {
err = tx.Model(&types.Node{}).Where("id = ?", node.ID).Update("ipv6", v6.String()).Error
if err != nil {
return fmt.Errorf("saving ip addresses to new columns: %w", err)
}
}
}
_ = tx.Migrator().DropColumn(&types.Node{}, "ip_addresses")