Documentation ¶
Index ¶
- func BinarySchemaVersion(dialect string) int
- func MigrateStore(ctx context.Context, dialect string, url string, opt ...Option) (bool, error)
- func TestCloneMigrationStates(t *testing.T) map[string]migrationState
- func TestCreatePartialMigrationState(om migrationState, maxVer int) migrationState
- type LogEntry
- type Manager
- func (b *Manager) CurrentState(ctx context.Context) (*State, error)
- func (b *Manager) ExclusiveLock(ctx context.Context) error
- func (b *Manager) ExclusiveUnlock(ctx context.Context) error
- func (b *Manager) RollForward(ctx context.Context) error
- func (b *Manager) SharedLock(ctx context.Context) error
- func (b *Manager) SharedUnlock(ctx context.Context) error
- type Option
- type State
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func BinarySchemaVersion ¶
BinarySchemaVersion provides the schema version that this binary supports for the provided dialect. If the binary doesn't support this dialect -1 is returned.
func MigrateStore ¶
MigrateStore executes the migrations needed to initialize the store. It returns true if migrations actually ran; false if the database is already current or if there was an error. Supports the WithMigrationStates(...) option.
func TestCloneMigrationStates ¶ added in v0.2.0
func TestCreatePartialMigrationState ¶ added in v0.2.0
func TestCreatePartialMigrationState(om migrationState, maxVer int) migrationState
Creates a new migrationState only with the versions <= the provided maxVer
Types ¶
type LogEntry ¶ added in v0.2.0
LogEntry represents a log entry generated during migrations.
func GetMigrationLog ¶ added in v0.2.0
GetMigrationLog will retrieve the migration logs from the db for the last migration. Once it's read the entries, it will delete them from the database.
The WithDeleteLog option is supported and will remove all log entries when provided.
type Manager ¶
type Manager struct {
// contains filtered or unexported fields
}
Manager provides a way to run operations and retrieve information regarding the underlying boundary database schema. Manager is not thread safe.
func NewManager ¶
NewManager creates a new schema manager. An error is returned if the provided dialect is unrecognized or if the passed in db is unreachable.
func (*Manager) CurrentState ¶
CurrentState provides the state of the boundary schema contained in the backing database.
func (*Manager) ExclusiveLock ¶
ExclusiveLock attempts to obtain an exclusive lock on the database. An error is returned if a lock was unable to be obtained.
func (*Manager) ExclusiveUnlock ¶
ExclusiveUnlock releases a shared lock on the database. If this fails for whatever reason an error is returned. Unlocking a lock that is not held is not an error.
func (*Manager) RollForward ¶
RollForward updates the database schema to match the latest version known by the boundary binary. An error is not returned if the database is already at the most recent version.
func (*Manager) SharedLock ¶
SharedLock attempts to obtain a shared lock on the database. This can fail if an exclusive lock is already held. If the lock can't be obtained an error is returned.
type Option ¶ added in v0.2.0
type Option func(*options)
Option - how Options are passed as arguments.
func WithDeleteLog ¶ added in v0.2.0
WithDeleteLog provides an option to specify the deletion of log entries.
func WithMigrationStates ¶ added in v0.2.0
WithMigrationStates provides an optional migration states.
type State ¶
type State struct { // InitializationStarted indicates if the current database has been initialized previously. InitializationStarted bool // Dirty is set to true if the database failed in a previous migration/initialization. Dirty bool // DatabaseSchemaVersion is the schema version that is currently running in the database. DatabaseSchemaVersion int // BinarySchemaVersion is the schema version which this boundary binary supports. BinarySchemaVersion int }
State contains information regarding the current state of a boundary database's schema.