Refactor database methods: simplify SaveEvent signature, enhance logging, and introduce deletion check logic with CheckForDeleted.

This commit is contained in:
2025-09-03 20:59:23 +01:00
parent 5cadf9c933
commit b08e94807b
26 changed files with 293 additions and 151 deletions

View File

@@ -14,11 +14,10 @@ import (
)
const (
currentVersion uint32 = 0
currentVersion uint32 = 1
)
func (d *D) RunMigrations() {
log.I.F("running migrations...")
var err error
var dbVersion uint32
// first find the current version tag if any
@@ -48,6 +47,7 @@ func (d *D) RunMigrations() {
); chk.E(err) {
return
}
log.I.F("found version tag: %d", ver.Get())
dbVersion = ver.Get()
}
return
@@ -62,9 +62,13 @@ func (d *D) RunMigrations() {
buf := new(bytes.Buffer)
vv := new(types.Uint32)
vv.Set(currentVersion)
log.I.S(vv)
if err = indexes.VersionEnc(vv).MarshalWrite(buf); chk.E(err) {
return
}
if err = txn.Set(buf.Bytes(), nil); chk.E(err) {
return
}
return
},
); chk.E(err) {
@@ -72,10 +76,10 @@ func (d *D) RunMigrations() {
}
}
if dbVersion < 1 {
log.I.F("migrating to version 1...")
// the first migration is expiration tags
d.UpdateExpirationTags()
}
log.I.F("migrations complete")
}
func (d *D) UpdateExpirationTags() {