eventstore: fix migrations annoyingly rerunning.

This commit is contained in:
fiatjaf
2025-08-05 13:09:50 -03:00
parent d79793c0f4
commit 144f4a4740
3 changed files with 7 additions and 7 deletions
+3 -3
View File
@@ -14,6 +14,8 @@ const (
DB_VERSION byte = 'v'
)
const target = 2
func (b *LMDBBackend) migrate() error {
return b.lmdbEnv.Update(func(txn *lmdb.Txn) error {
val, err := txn.Get(b.settingsStore, []byte("version"))
@@ -21,13 +23,11 @@ func (b *LMDBBackend) migrate() error {
return fmt.Errorf("failed to get db version: %w", err)
}
var version uint16 = 1
var version uint16 = target
if err == nil {
version = binary.BigEndian.Uint16(val)
}
const target = 2
// do the migrations in increasing steps (there is no rollback)
if version < target {
log.Printf("[lmdb] migration %d: reindex everything\n", target)