migrations

package
v1.3.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 1, 2024 License: BSD-3-Clause Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Migrate

func Migrate(txn *badger.Txn) (err error)

Migrate the database to the current version or ensure that the database is current.

func Migration0001

func Migration0001(txn *badger.Txn) error

Migration0001 converts the key-length based identification of keyspace to a bucket oriented approach with prefixes that will allow us to list objects in the database.

Types

type MigrateFn

type MigrateFn func(txn *badger.Txn) error

type Migration

type Migration struct {
	Version  uint16     `msgpack:"version"`
	Applied  time.Time  `msgpack:"applied"`
	Previous *Migration `msgpack:"previous"`
	Migrate  MigrateFn  `msgpack:"-"`
}

Migration represents any changes that must be applied to the database using the MigrateFn defined in the migration. This data structure is saved in the datbase to identify what the database migration is currently at. To define a new migration, create a file with m000n.go then create a migration instance and register it. The store will automatically check the migration is at the latest version or apply the migrations in order if the database is not at the latest version.

func Current

func Current(txn *badger.Txn) (_ *Migration, err error)

func (*Migration) Key

func (m *Migration) Key() []byte

func (*Migration) MarshalValue

func (m *Migration) MarshalValue() ([]byte, error)

func (*Migration) UnmarshalValue

func (m *Migration) UnmarshalValue(data []byte) error

type Migrations

type Migrations []*Migration

func (Migrations) HasNext

func (m Migrations) HasNext(n *Migration) bool

func (Migrations) Next

func (m Migrations) Next(n *Migration) *Migration

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL