boltdb support.

This commit is contained in:
fiatjaf
2024-02-08 12:36:34 -03:00
parent 830d51e96d
commit 9d87d1fd8a
9 changed files with 647 additions and 0 deletions

32
bolt/migration.go Normal file
View File

@@ -0,0 +1,32 @@
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
})
}