Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ParseMigrationPair ¶
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 (*FS) GetMigrations ¶
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".