zmigrate

package
v0.6.2 Latest Latest
Warning

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

Go to latest
Published: Jan 25, 2022 License: MIT Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrInvalidVersion   = errors.New("invalid version number")
	ErrMigrationChanged = errors.New("a migration has changed since it was originally run")
)

Functions

This section is empty.

Types

type Config

type Config struct {
	Table           string
	SkipTransaction bool
}

type Migrator

type Migrator struct {
	Source fs.ReadDirFS

	Driver drivers.Driver
	// contains filtered or unexported fields
}

func New

func New(source fs.ReadDirFS, db zsql.DB, config *Config) *Migrator

func (*Migrator) GetSchema

func (m *Migrator) GetSchema() (schema drivers.Schema, err error)

Get a schema representation based on the underlying driver

func (*Migrator) ToVersion

func (m *Migrator) ToVersion(version int) (err error)

Migrate up or down to a specific state in the db. This allows you to work on your schema without ruining existing environments by locking it to a version.

type Seed added in v0.6.2

type Seed struct {
	Name    string
	Version int
	Handler SeedHandler
}

type SeedHandler added in v0.6.2

type SeedHandler func(ctx context.Context, tx zsql.Tx, seed Seed) error

type Seeder added in v0.6.2

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

func NewSeeder added in v0.6.2

func NewSeeder(db zsql.DB, config *SeederConfig) (s *Seeder, err error)

func (*Seeder) AddSeed added in v0.6.2

func (s *Seeder) AddSeed(name string, version int, handler SeedHandler) *Seeder

Add a seed handler for the specified name/version

func (*Seeder) SeedTo added in v0.6.2

func (s *Seeder) SeedTo(name string, targetVersion int) (err error)

Seed the given name to the specified version. Does nothing if the version is already satisfied. Can only seed forwards and not backwards

type SeederConfig added in v0.6.2

type SeederConfig struct {
	TableName string
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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