golang

package
v0.11.0 Latest Latest
Warning

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

Go to latest
Published: Jul 25, 2018 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func New added in v0.5.0

func New(source *Source, updateVersion UpdateVersion, applied AppliedVersions, config *Config) (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 AppliedVersions added in v0.5.0

type AppliedVersions func(config *Config) ([]string, error)

type Config added in v0.5.0

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

func NewConfig added in v0.5.0

func NewConfig() *Config

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

func (*Config) Get added in v0.5.0

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

Get retrieves a value from the configuration using the key.

func (*Config) Set added in v0.5.0

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

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

type Driver added in v0.5.0

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

func (*Driver) Close added in v0.5.0

func (g *Driver) Close() error

func (*Driver) Migrate added in v0.5.0

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

func (*Driver) Versions added in v0.5.0

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

Version returns all applied migration versions

type Source added in v0.5.0

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

func NewSource added in v0.5.0

func NewSource() *Source

NewGolangSource creates a source for storing Go functions as migrations.

func (*Source) AddMigration added in v0.5.0

func (s *Source) AddMigration(file string, direction m.Direction, migration func(c *Config) 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 (*Source) GetMigrationFile added in v0.5.0

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

GetMigrationFile retrieves a migration given the filename.

func (*Source) ListMigrationFiles added in v0.5.0

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

ListMigrationFiles lists the available migrations in the source

type UpdateVersion added in v0.5.0

type UpdateVersion func(id string, direction m.Direction, config *Config) error

Jump to

Keyboard shortcuts

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