migrations

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Sep 16, 2026 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Overview

Package migrations embeds the kit's SQL schema, one file set per dialect. Both dialects define the identical table/constraint set (R7); migrations_test cross-checks them against each other and against the storage package's Go enum sets.

Index

Constants

This section is empty.

Variables

FS holds the embedded migration files, laid out as <dialect>/<NNNN>_<name>.sql.

Functions

func Apply

func Apply(ctx context.Context, db *sql.DB, d Dialect) ([]string, error)

Apply runs every pending migration for the dialect inside one transaction per file, tracking applied files in schema_migrations. It returns the names it applied. Callers pass an already-open *sql.DB (the driver registration lives in storage/sqlite and storage/postgres).

func Files

func Files(d Dialect) ([]string, error)

Files returns the dialect's migration file names in apply order (lexicographic — files are NNNN-prefixed).

func Read

func Read(d Dialect, name string) (string, error)

Read returns one migration file's SQL text.

func Statements

func Statements(sqlText string) []string

Statements splits migration SQL into single executable statements so both drivers apply them one Exec per statement (pgx extended protocol rejects multi-statement strings). Migration files therefore must not contain ';' inside string literals or comments; TestStatementsRoundTrip enforces the split is lossless for the embedded files.

Types

type Dialect

type Dialect string

Dialect selects a migration file set.

const (
	DialectSQLite   Dialect = "sqlite"
	DialectPostgres Dialect = "postgres"
)

func (Dialect) Valid

func (d Dialect) Valid() bool

Valid reports whether d is a known dialect.

Jump to

Keyboard shortcuts

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