Files
eventstore/bolt/migration.go
2024-02-08 12:36:34 -03:00

33 lines
490 B
Go

package bolt
import (
"encoding/binary"
"github.com/boltdb/bolt"
)
const (
DB_VERSION byte = 'v'
)
func (b *BoltBackend) runMigrations() error {
return b.db.Update(func(txn *bolt.Tx) error {
var version uint16
v := txn.Bucket(bucketSettings).Get([]byte{DB_VERSION})
if v == nil {
version = 0
} else {
version = binary.BigEndian.Uint16(v)
}
// do the migrations in increasing steps (there is no rollback)
//
if version < 0 {
// ...
}
return nil
})
}