sqlmigrate

package
v0.1.3 Latest Latest
Warning

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

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

Documentation

Overview

Package sqlmigrate applies a service's embedded migration files to a database/sql handle, so a service's store directory holds its .sql files and nothing else: the files are the only schema source, and this is the one runner that reads them.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Apply

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

Apply brings db up to every *.up.sql file under dir in files, in name order, skipping the ones schema_migrations already records. Each file is executed one statement at a time so a driver that runs one statement per call (candace/pkg/pgmem in tests) applies the same bytes production does.

func ApplyPrefixed

func ApplyPrefixed(ctx context.Context, db *sql.DB, files fs.FS, dir string, prefix string) error

ApplyPrefixed applies a component schema while namespacing its migration receipts in a database shared with an owning application. Prefix is only a ledger namespace; it never changes the embedded filename or execution order.

func Statements

func Statements(body string) []string

Statements splits one migration file into the statements it holds. The files hold plain DDL with no semicolons inside literals. Full-line -- comments are removed before semicolons are interpreted as delimiters.

Types

This section is empty.

Jump to

Keyboard shortcuts

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