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:
Bethuel Mmbaga
2024-05-07 14:01:45 +03:00
committed by GitHub
parent c590518e0c
commit ce0718fcb5
5 changed files with 196 additions and 5 deletions

View File

@@ -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