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

migrate

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Oct 21, 2026 License: MIT Imports: 18 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrUnknownAppliedVersion = errors.New(
		"the database has migrations applied that this checkout does not have (switched branches?): reset the database",
	).WithCode("UNKNOWN_APPLIED_MIGRATION")

	ErrNothingToRollBack = errors.New("no migration is applied: there is nothing to roll back").
							WithCode("NOTHING_TO_ROLL_BACK")

	ErrMigrate = errors.New("failed to run migrations")

	ErrUsage = errors.New("usage: migrate [direction], with direction one of the listed ones").
				WithCode("MIGRATIONS_USAGE").
				WithAttribute("directions", strings.Join(slices.Sorted(maps.Keys(directions)), ", "))

	ErrDatabaseURL = errors.New("failed to read the database URL")

	ErrConnectDatabase = errors.New("failed to connect to the database: is Postgres up and the database URL right?")
)

Functions

func Down

func Down(ctx context.Context, db *sql.DB, migrations fs.FS) error

func Run

func Run(args []string, migrations fs.FS, databaseURL func() (string, error))

Run is the body of a migrate binary: args are its command-line arguments, and it exits non-zero when the migrations fail.

func Up

func Up(ctx context.Context, db *sql.DB, migrations fs.FS) error

Types

This section is empty.

Jump to

Keyboard shortcuts

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