mirror of
https://github.com/netbirdio/netbird.git
synced 2026-04-19 00:36:38 +00:00
Migrate blob net ip fields to json serializer (#1906)
* serialize net.IP as json * migrate net ip field from blob to json * run net ip migration * remove duplicate index * Refactor * Add tests * fix tests * migrate null blob values
This commit is contained in:
@@ -519,15 +519,29 @@ func TestMigrate(t *testing.T) {
|
||||
Net net.IPNet `gorm:"serializer:gob"`
|
||||
}
|
||||
|
||||
type location struct {
|
||||
nbpeer.Location
|
||||
ConnectionIP net.IP
|
||||
}
|
||||
|
||||
type peer struct {
|
||||
nbpeer.Peer
|
||||
Location location `gorm:"embedded;embeddedPrefix:location_"`
|
||||
}
|
||||
|
||||
type account struct {
|
||||
Account
|
||||
Network *network `gorm:"embedded;embeddedPrefix:network_"`
|
||||
Peers []peer `gorm:"foreignKey:AccountID;references:id"`
|
||||
}
|
||||
|
||||
act := &account{
|
||||
Network: &network{
|
||||
Net: *ipnet,
|
||||
},
|
||||
Peers: []peer{
|
||||
{Location: location{ConnectionIP: net.IP{10, 0, 0, 1}}},
|
||||
},
|
||||
}
|
||||
|
||||
err = store.db.Save(act).Error
|
||||
|
||||
Reference in New Issue
Block a user