migrations

package
v0.8.0 Latest Latest
Warning

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

Go to latest
Published: Mar 10, 2026 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrInvalidMigrationExt  = errors.New("invalid migration ext")
	ErrInvalidMigrationName = errors.New("invalid migration name")
)

Errors.

View Source
var ErrInvalidVersion = errors.New("invalid version")
View Source
var ErrUnknownCommand = errors.New("unknown command")

Functions

func Run

func Run(ctx context.Context, driver string, connector database.Connector, cmd Command, migrations Migrations) error

Run execute every 'delimUp' instructions for every migration.

Types

type Command

type Command uint8

Command of migration.

const (
	Up   Command // up
	Down         // down
)

Enum.

func (Command) String

func (i Command) String() string

type Migration

type Migration struct {
	Version uint
	Name    string
	Up      string
	Down    string
}

Migration information for UP and Down sql query.

type Migrations

type Migrations []Migration

Migrations for easy sorting list of migrations.

func FromFS

func FromFS(directory fs.FS, root string) (Migrations, error)

FromFS build migrations from file system.

func Parse

func Parse(path string) (Migrations, error)

Parse and build migrations from disk.

func (Migrations) Len

func (m Migrations) Len() int

Len implements sort.Interface.

func (Migrations) Less

func (m Migrations) Less(i, j int) bool

Less implements sort.Interface.

func (Migrations) Swap

func (m Migrations) Swap(i, j int)

Swap implements sort.Interface.

Jump to

Keyboard shortcuts

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