gomigrator

package module
v0.0.2 Latest Latest
Warning

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

Go to latest
Published: Mar 20, 2022 License: MIT Imports: 6 Imported by: 1

README

go-migrator

A library to help setup migrations for Relational databases.

Documentation

Index

Constants

View Source
const MigrateToLatest = "MIGRATE_TO_LATEST"
View Source
const MigrateToNothing = "MIGRATE_TO_NOTHING"

Variables

This section is empty.

Functions

This section is empty.

Types

type ErrCouldNotCreateMigrationsTable

type ErrCouldNotCreateMigrationsTable struct {
	Wrapped       error
	RollbackError error
	CommitError   error
}

func (ErrCouldNotCreateMigrationsTable) Error

type ErrCouldNotExecuteMigration

type ErrCouldNotExecuteMigration struct {
	Name          string
	Wrapped       error
	RollbackError error
	CommitError   error
}

func (ErrCouldNotExecuteMigration) Error

type ErrCouldNotRollbackMigration

type ErrCouldNotRollbackMigration struct {
	Name          string
	Wrapped       error
	RollbackError error
	CommitError   error
}

func (ErrCouldNotRollbackMigration) Error

type ErrInvalidMigrationInstruction

type ErrInvalidMigrationInstruction struct {
	Message string
}

func (ErrInvalidMigrationInstruction) Error

type ErrInvalidOpts

type ErrInvalidOpts struct {
	Message string
}

func (ErrInvalidOpts) Error

func (e ErrInvalidOpts) Error() string

type ErrMigrationNotFound

type ErrMigrationNotFound struct {
	Id string
}

func (ErrMigrationNotFound) Error

func (e ErrMigrationNotFound) Error() string

type ErrMigrationsNotImplementedForDriver

type ErrMigrationsNotImplementedForDriver struct {
	Driver string
}

func (ErrMigrationsNotImplementedForDriver) Error

type ErrNoMigrationsFound

type ErrNoMigrationsFound struct{}

func (ErrNoMigrationsFound) Error

func (e ErrNoMigrationsFound) Error() string

type Migration

type Migration struct {
	Id       string
	Name     string
	Execute  MigrationExecutor
	Rollback MigrationExecutor
}

type MigrationDirection

type MigrationDirection string
const MigrationDown MigrationDirection = "down"
const MigrationUp MigrationDirection = "up"

type MigrationExecutor

type MigrationExecutor func(tx *sqlx.Tx) (sql.Result, error)

type MigrationInstruction

type MigrationInstruction struct {
	Direction MigrationDirection
	Target    string
}

type MigrationList

type MigrationList struct {
	// contains filtered or unexported fields
}

func NewMigrationList

func NewMigrationList(migs []Migration) MigrationList

func (MigrationList) All

func (ml MigrationList) All() []Migration

func (MigrationList) GetFirstMigration

func (ml MigrationList) GetFirstMigration() (*Migration, bool)

func (MigrationList) GetLatestMigration

func (ml MigrationList) GetLatestMigration() (*Migration, bool)

func (MigrationList) MigrationsFromId

func (ml MigrationList) MigrationsFromId(id string) ([]Migration, error)

func (MigrationList) MigrationsUpToId

func (ml MigrationList) MigrationsUpToId(id string) ([]Migration, error)

type MigrationOpts

type MigrationOpts struct {
	Schema  string
	Applyer string
}

type MigrationRecord

type MigrationRecord struct {
	Id     string
	Status string
	Events []MigrationRecordEvent
}

type MigrationRecordDb

type MigrationRecordDb struct {
	Id     string
	Status string
	Events string
}

type MigrationRecordEvent

type MigrationRecordEvent struct {
	Action      string
	Actor       string
	PerformedAt string
	Result      string
}

type MigrationState

type MigrationState string
const MigrationApplied MigrationState = "applied"
const MigrationFailed MigrationState = "failed"
const MigrationPending MigrationState = "pending"
const MigrationRollbackFailed MigrationState = "rollback_failed"
const MigrationRolledBack MigrationState = "rolled_back"

type Migrator

type Migrator struct {
	// contains filtered or unexported fields
}

func NewMigrator

func NewMigrator(dbConn *sqlx.DB, migs MigrationList, opts Opts, logger zerolog.Logger) (*Migrator, error)

func (*Migrator) Down

func (m *Migrator) Down(t string) error

func (*Migrator) ListMigrations

func (m *Migrator) ListMigrations() ([]*MigrationRecord, error)

func (*Migrator) Up

func (m *Migrator) Up(t string) error

type Opts

type Opts struct {
	Schema  string
	Applyer string
}

Directories

Path Synopsis
test

Jump to

Keyboard shortcuts

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