migrate

package
v0.0.0-...-4c964c4 Latest Latest
Warning

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

Go to latest
Published: Jul 29, 2025 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Overview

Package migrate provides simple migration functions Up, Down, and To, as well as a Migrator. Up, Down, and To are one-liner convenience functions that use default Options. If you need custom Options, use New.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Down

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

Down from the current version.

func To

func To(ctx context.Context, db *sql.DB, fsys fs.FS, version string) error

To the given version.

func Up

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

Up from the current version.

Types

type Migrator

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

func New

func New(opts Options) *Migrator

New Migrator with Options. If Options.Table is not set, defaults to "migrations". The table name must match ^[\w.]+$ . New panics on illegal options.

func (*Migrator) MigrateDown

func (m *Migrator) MigrateDown(ctx context.Context) (err error)

MigrateDown from the current version.

func (*Migrator) MigrateTo

func (m *Migrator) MigrateTo(ctx context.Context, version string) (err error)

func (*Migrator) MigrateUp

func (m *Migrator) MigrateUp(ctx context.Context) (err error)

MigrateUp from the current version.

type Options

type Options struct {
	After      callback
	Before     callback
	DriverName string
	DB         *sql.DB
	FS         fs.FS
	Table      string
}

Options for New. DB and FS are always required.

Jump to

Keyboard shortcuts

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