sqlmigrate

package
v0.3.2 Latest Latest
Warning

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

Go to latest
Published: Aug 19, 2026 License: AGPL-3.0 Imports: 8 Imported by: 0

Documentation

Overview

Package sqlmigrate applies embedded goose migrations to a SQLite database. Every store (internal/store, internal/host/store) funnels through here so the repo has exactly one migration mechanism.

Migrations are goose-format .sql files generated from each store's declarative schema.sql via `make migration` (Atlas computes the diff); this package only ever applies them.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DumpSchema

func DumpSchema(db *sql.DB) (string, error)

DumpSchema returns a normalized, deterministic description of db's user-visible schema: one line per table column and per index. Built for the per-store schema-identity tests (goose-migrated database ≡ schema.sql), which is what keeps sqlc's input honest against what actually runs.

Tables are described structurally (pragma_table_info) because SQLite rewrites a table's stored CREATE text on every ALTER, making text comparison meaningless once real migrations exist. Index DDL is never rewritten, so indexes compare by normalized statement text — which also covers partial-index WHERE clauses that pragmas can't see. CHECK constraints are invisible to both views; the Atlas sync check in CI (`make migrations-check`) covers those semantically.

func Up

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

Up applies every pending migration to db, in order. migrations must be a filesystem whose root contains the goose-format .sql files. Safe to call on every open: applied versions are tracked per-migration in the goose_db_version table, so reruns are no-ops.

Types

This section is empty.

Jump to

Keyboard shortcuts

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