source

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Aug 7, 2026 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ParseMigrationPair

func ParseMigrationPair(id string, upContent, downContent []byte) (*migrator.Migration, error)

ParseMigrationPair builds a Migration from the contents of an <id>.up.sql / <id>.down.sql file pair.

Each file is plain SQL, optionally preceded by a single directive line:

-- +migrate notransaction
CREATE INDEX CONCURRENTLY idx_users_email ON users(email);

A migration that cannot be undone says so in its .down.sql instead of leaving it empty:

-- +migrate irreversible

Types

type FS

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

FS reads migration file pairs from an fs.FS.

func NewFS

func NewFS(fsys fs.FS) *FS

NewFS creates a new FS source that reads migrations from the specified fs.FS.

func (*FS) GetMigrations

func (f *FS) GetMigrations() ([]*migrator.Migration, error)

GetMigrations reads and parses all migrations from the source fs.FS.

A migration is a pair of files, <id>.up.sql and <id>.down.sql, and its ID is the shared base name. Both halves are required: a missing rollback script is an error, because an empty one would let automatic recovery and branch-switch rollback "succeed" while doing nothing and still drop the ledger row, leaving the schema silently drifted.

Only the top-level directory is read; subdirectories are not traversed. Files that are not .sql are ignored, but a .sql file that is neither *.up.sql nor *.down.sql is an error rather than a silent skip — in a migrations directory the only acceptable outcomes for a .sql file are "it runs" and "you were told why it did not".

Jump to

Keyboard shortcuts

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