badger

package
v0.2.6 Latest Latest
Warning

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

Go to latest
Published: Dec 4, 2018 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func MigrateLatest added in v0.2.6

func MigrateLatest(db *badger.DB, id string) error

MigrateLatest converts the database to the latest version that we know of.

func Open

func Open(opts badger.Options) (*badgerStore, error)

Open returns a store.Store implementation using Badger as the storage driver. The store should be (*badgerStore).Close()'d after use.

Types

type Migration added in v0.2.6

type Migration struct {
	// StartVersion is the minimum version that is supported by the migration.
	StartVersion int
	// LatestVersion is the final version that we should expect after running migrations.
	LatestVersion int
	// Steps are the migration steps for transforming the database state across versions when run in sequence.
	Steps []MigrationStep
	// DatabaseID is an identifier for the database being migrated (e.g. opts.Dir), used for more descriptive errors.
	DatabaseID string
}

Migration handles transforming the database state to the newest version.

func (*Migration) Migrate added in v0.2.6

func (m *Migration) Migrate(db *badger.DB) error

Migrate performs the migration sequence.

type MigrationError added in v0.2.3

type MigrationError struct {
	OldVersion int
	NewVersion int
	Path       string
	Cause      error
}

MigrationError is returned when the database is opened with an outdated version and migation fails.

func (MigrationError) Error added in v0.2.3

func (err MigrationError) Error() string

type MigrationStep added in v0.2.6

type MigrationStep func(txn *badger.Txn) error

MigrationStep is called within an update transaction with the current version. It should update the database state to the next version. The migration step should update the database version with each step.

Jump to

Keyboard shortcuts

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