migrate

package
v1.2.1 Latest Latest
Warning

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

Go to latest
Published: Feb 2, 2026 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	DefaultXMigrationsTable = "schema_migrations"
	DefaultSource           = "file://desc/sql_migration"
)

Functions

func WithSource

func WithSource(source string) opts.Opt[MigrateOpts]

func WithSourceAppendDriver

func WithSourceAppendDriver(sourceAppendDriver bool) opts.Opt[MigrateOpts]

func WithXMigrationsTable

func WithXMigrationsTable(xMigrationsTable string) opts.Opt[MigrateOpts]

Types

type Driver

type Driver string
const (
	MySQL  Driver = "mysql"
	Pgx    Driver = "pgx"
	Sqlite Driver = "sqlite"
)

type Migrate

type Migrate interface {
	// Up looks at the currently active migration version
	// and will migrate all the way up (default applying all up migrations).
	Up(steps ...uint) error

	// Down looks at the currently active migration version
	// and will migrate all the way down (default applying all down migrations).
	Down(steps ...uint) error

	// Goto looks at the currently active migration version,
	// then migrates either up or down to the specified version.
	Goto(version uint) error

	// Version returns the currently active migration version.
	// If no migration has been applied, yet, it will return ErrNilVersion.
	Version() (version uint, dirty bool, err error)

	// Close source and database, return source error and database error
	Close() (error, error)
}

func NewMigrate

func NewMigrate(sqlConf sqlx.SqlConf, op ...opts.Opt[MigrateOpts]) (Migrate, error)

type MigrateOpts

type MigrateOpts struct {
	Source             string
	SourceAppendDriver bool
	XMigrationsTable   string
}

func (MigrateOpts) DefaultOptions

func (d MigrateOpts) DefaultOptions() MigrateOpts

Jump to

Keyboard shortcuts

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