Documentation ¶
Index ¶
- func Migrate(driver Driver, migrations Source, direction Direction, max int) (int, error)
- func SetLogger(l *log.Logger)
- type Direction
- type Driver
- type GoBindataMigrationSource
- type GolangMigrationSource
- func (s *GolangMigrationSource) AddMigration(file string, direction Direction, migration func() error)
- func (s *GolangMigrationSource) GetMigration(file string) func() error
- func (s *GolangMigrationSource) GetMigrationFile(file string) (io.Reader, error)
- func (s *GolangMigrationSource) ListMigrationFiles() ([]string, error)
- type MemoryMigrationSource
- type Migration
- type PackrBox
- type PackrMigrationSource
- type PlannedMigration
- type Source
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Driver ¶
type Driver interface { // Close is the last function to be called. // Close any open connection here. Close() error // Migrate is the heart of the driver. // It will receive a PlannedMigration which the driver should apply // to its backend or whatever. Migrate(migration *PlannedMigration) error // Version returns all applied migration versions Versions() ([]string, error) }
Driver is the interface type that needs to implemented by all drivers.
type GoBindataMigrationSource ¶ added in v0.11.0
type GoBindataMigrationSource struct { // Asset should return content of file in path if exists Asset func(path string) ([]byte, error) // AssetDir should return list of files in the path AssetDir func(path string) ([]string, error) // Path in the bindata to use. Dir string }
GoBindataMigrationSource is a MigrationSource that uses migration files embedded in a Go application using go-bindata.
func (GoBindataMigrationSource) GetMigrationFile ¶ added in v0.11.0
func (a GoBindataMigrationSource) GetMigrationFile(name string) (io.Reader, error)
GetMigrationFile gets a gobindata migration file
func (GoBindataMigrationSource) ListMigrationFiles ¶ added in v0.11.0
func (a GoBindataMigrationSource) ListMigrationFiles() ([]string, error)
ListMigrationFiles returns a list of gobindata migration files
type GolangMigrationSource ¶ added in v0.15.0
GolangMigrationSource implements migration.Source
func NewGolangMigrationSource ¶ added in v0.15.0
func NewGolangMigrationSource() *GolangMigrationSource
NewGolangMigrationSource creates a source for storing Go functions as migrations.
func (*GolangMigrationSource) AddMigration ¶ added in v0.15.0
func (s *GolangMigrationSource) AddMigration(file string, direction Direction, migration func() error)
AddMigration adds a new migration to the source. The file parameter follows the same conventions as you would use for a physical file for other types of migrations, however you should omit the file extension. Example: 1_init.up and 1_init.down
func (*GolangMigrationSource) GetMigration ¶ added in v0.15.0
func (s *GolangMigrationSource) GetMigration(file string) func() error
GetMigration gets a golang migration
func (*GolangMigrationSource) GetMigrationFile ¶ added in v0.15.0
func (s *GolangMigrationSource) GetMigrationFile(file string) (io.Reader, error)
GetMigrationFile retrieves a migration given the filename.
func (*GolangMigrationSource) ListMigrationFiles ¶ added in v0.15.0
func (s *GolangMigrationSource) ListMigrationFiles() ([]string, error)
ListMigrationFiles lists the available migrations in the source
type MemoryMigrationSource ¶
MemoryMigrationSource is a MigrationSource that uses migration sources in memory. It is mainly used for testing.
func (MemoryMigrationSource) GetMigrationFile ¶
func (m MemoryMigrationSource) GetMigrationFile(name string) (io.Reader, error)
GetMigrationFile gets a memory migration file
func (MemoryMigrationSource) ListMigrationFiles ¶
func (m MemoryMigrationSource) ListMigrationFiles() ([]string, error)
ListMigrationFiles returns a list of memory migration files
type Migration ¶
type Migration struct { ID string Up *parser.ParsedMigration Down *parser.ParsedMigration }
Migration represents a migration, containing statements for migrating up and down.
func (Migration) NumberPrefixMatches ¶
NumberPrefixMatches returns a list of string matches
func (Migration) VersionInt ¶
VersionInt converts the migration version to an 64-bit integer.
type PackrBox ¶ added in v0.11.0
PackrBox avoids pulling in the packr library for everyone, mimics the bits of packr.Box that we need.
type PackrMigrationSource ¶ added in v0.11.0
PackrMigrationSource holds the box and dir info
func (PackrMigrationSource) GetMigrationFile ¶ added in v0.11.0
func (p PackrMigrationSource) GetMigrationFile(name string) (io.Reader, error)
GetMigrationFile gets a packr migration file
func (PackrMigrationSource) ListMigrationFiles ¶ added in v0.11.0
func (p PackrMigrationSource) ListMigrationFiles() ([]string, error)
ListMigrationFiles returns a list of packr migration files
type PlannedMigration ¶
PlannedMigration is a migration with a direction defined. This allows the driver to work out how to apply the migration.