boltdb support.
This commit is contained in:
32
bolt/migration.go
Normal file
32
bolt/migration.go
Normal 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
|
||||
})
|
||||
}
|
||||
Reference in New Issue
Block a user