golang

package
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: Mar 22, 2017 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewGolang

func NewGolang(source *GolangSource, updateVersion UpdateVersionFunc, applied AppliedVersionsFunc, config *GolangConfig) (m.Driver, error)

NewGolang creates a new Go migration driver. It requires a source a function for saving the executed migration version, a function for deleting a version that was migrated downwards, a function for listing all applied migrations and optionally a configuration.

Types

type AppliedVersionsFunc

type AppliedVersionsFunc func(config *GolangConfig) ([]string, error)

type Golang

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

func (*Golang) Close

func (g *Golang) Close() error

func (*Golang) Migrate

func (g *Golang) Migrate(migration *m.PlannedMigration) error

func (*Golang) Versions

func (g *Golang) Versions() ([]string, error)

Version returns all applied migration versions

type GolangConfig

type GolangConfig struct {
	sync.Mutex
	// contains filtered or unexported fields
}

func NewGolangConfig

func NewGolangConfig() *GolangConfig

NewGolangConfig creates a concurrency-safe configuration map for passing configuration data and things like database handlers to your migrations.

func (*GolangConfig) Get

func (c *GolangConfig) Get(key interface{}) interface{}

Get retrieves a value from the configuration using the key.

func (*GolangConfig) Set

func (c *GolangConfig) Set(key, val interface{})

Set adds a new key-value pair to the configuration.

type GolangSource

type GolangSource struct {
	sync.Mutex
	// contains filtered or unexported fields
}

func NewGolangSource

func NewGolangSource() *GolangSource

NewGolangSource creates a source for storing Go functions as migrations.

func (*GolangSource) AddMigration

func (s *GolangSource) AddMigration(file string, direction m.Direction, migration func(c *GolangConfig) 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 (*GolangSource) GetMigrationFile

func (s *GolangSource) GetMigrationFile(file string) (io.Reader, error)

GetMigrationFile retrieves a migration given the filename.

func (*GolangSource) ListMigrationFiles

func (s *GolangSource) ListMigrationFiles() ([]string, error)

ListMigrationFiles lists the available migrations in the source

type UpdateVersionFunc

type UpdateVersionFunc func(id string, direction m.Direction, config *GolangConfig) error

Jump to

Keyboard shortcuts

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