updated collection indexes on system fields validator and normalized v0.23 old collections migration

This commit is contained in:
Gani Georgiev
2024-11-15 09:11:45 +02:00
parent e53c30ca4d
commit 18a7549e50
6 changed files with 140 additions and 24 deletions

View File

@@ -10,12 +10,12 @@ import (
// note: this migration will be deleted in future version
func collectionIdChecksum(c *core.Collection) string {
return "pbc_" + strconv.Itoa(int(crc32.ChecksumIEEE([]byte(c.Type+c.Name))))
func collectionIdChecksum(typ, name string) string {
return "pbc_" + strconv.Itoa(int(crc32.ChecksumIEEE([]byte(typ+name))))
}
func fieldIdChecksum(f core.Field) string {
return f.Type() + strconv.Itoa(int(crc32.ChecksumIEEE([]byte(f.GetName()))))
func fieldIdChecksum(typ, name string) string {
return typ + strconv.Itoa(int(crc32.ChecksumIEEE([]byte(name))))
}
// normalize system collection and field ids
@@ -62,7 +62,7 @@ func init() {
originalId := c.Id
// normalize collection id
if checksum := collectionIdChecksum(c); c.Id != checksum {
if checksum := collectionIdChecksum(c.Type, c.Name); c.Id != checksum {
c.Id = checksum
needUpdate = true
}
@@ -73,7 +73,7 @@ func init() {
continue
}
if checksum := fieldIdChecksum(f); f.GetId() != checksum {
if checksum := fieldIdChecksum(f.Type(), f.GetName()); f.GetId() != checksum {
f.SetId(checksum)
needUpdate = true
}