migrations

package
v1.0.3 Latest Latest
Warning

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

Go to latest
Published: Oct 23, 2026 License: MIT Imports: 13 Imported by: 1 module, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package migrations applies embedded SQL migrations and builds their shared CLI command.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Command

func Command[P any](config boa.Cmd[P], path *string, files fs.FS, open func(context.Context, string, bool) (*sql.DB, error)) *cobra.Command

Command creates migration subcommands for files containing migrations/*.sql. Config parameters used by subcommands must be persistent. open must not run migrations. Only up requests creation; Command closes the database.

func Down

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

Down rolls back the latest applied migration. It may destroy application data.

func Up

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

Up applies every pending migration, committing each with its metadata.

Types

type Status

type Status struct {
	Version     int    `json:"version"`
	Filename    string `json:"filename"`
	SHA256      string `json:"sha256"`
	AppliedAtMS *int64 `json:"applied_at_ms"`
	Applied     bool   `json:"applied"`
}

func List

func List(ctx context.Context, db *sql.DB, files fs.FS) ([]Status, error)

List inspects migration history without creating schema or metadata.

Jump to

Keyboard shortcuts

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