Help us shape the future of Go! Take the 2026 Go Developer Survey

gomigrate

package module
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Dec 16, 2021 License: MIT Imports: 11 Imported by: 0

README

gomigrate

Execute your database migrations as code. A tool for executing database migrations in Golang.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	Driver   string
	Username string
	Password string
	Host     string
	Port     string
	Database string
	Options  map[string]string
}

func (*Config) URL

func (c *Config) URL() string

type Migration

type Migration struct {
	Name string

	Deprecated bool
	Up         string
	UpFn       func(context.Context, *sql.DB) error
	UpTest     func(context.Context, *sql.DB, *testing.T)
	Down       string
	DownFn     func(context.Context, *sql.DB) error
	DownTest   func(context.Context, *sql.DB, *testing.T)
	// contains filtered or unexported fields
}

type Migrator

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

func NewMigrator

func NewMigrator(c *Config) *Migrator

func (*Migrator) AddMigration

func (m *Migrator) AddMigration(migration *Migration)

func (*Migrator) AddMigrations

func (m *Migrator) AddMigrations(steps ...*Migration) []*Migration

func (*Migrator) CurrentVersion

func (m *Migrator) CurrentVersion(ctx context.Context) (int64, error)

func (*Migrator) Len

func (m *Migrator) Len() int64

func (*Migrator) Reset

func (m *Migrator) Reset(ctx context.Context) (int64, error)

func (*Migrator) Rollback

func (m *Migrator) Rollback(ctx context.Context) (int64, error)

func (*Migrator) RollbackTo

func (m *Migrator) RollbackTo(ctx context.Context, targetVersion int64) (int64, error)

func (*Migrator) Run

func (m *Migrator) Run(ctx context.Context) (int64, error)

func (*Migrator) RunAllTests

func (m *Migrator) RunAllTests(t *testing.T)

func (*Migrator) RunDownTests

func (m *Migrator) RunDownTests(t *testing.T)

func (*Migrator) RunUpTests

func (m *Migrator) RunUpTests(t *testing.T)

func (*Migrator) Step

func (m *Migrator) Step(ctx context.Context, db *sql.DB) (int64, error)

func (*Migrator) StepTo

func (m *Migrator) StepTo(ctx context.Context, targetVersion int64) (int64, error)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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