migrate: thin Goose Provider convention with embedded migrations #7

Closed
opened 2026-10-26 22:16:25 -07:00 by end · 0 comments
Owner

Root-module package go.auvem.com/corestack/migrate. It sets the house convention for SQL migrations on Goose (github.com/pressly/goose/v3), using its Provider API. Migrations are embedded in the binary so daemons can migrate at startup.

Clean-room rewrite. Build from this spec. Don't read or port go-toolkit/migrate.

Requirements

  • No dependency on lifecycle. The adapter is a separate issue.
  • Construction takes a *sql.DB, a dialect, and an embed.FS plus a directory.
  • Operations: up, up-to, down-to, status, and current version. Also "are migrations pending?", so services can refuse to start or report not-ready.
  • Concurrent startups. It must be safe when several replicas or daemons start at once: use Goose's session locker on Postgres, and document the behaviour on other dialects.
  • Go-function migrations are allowed alongside SQL ones.
  • Logging goes through an injected *slog.Logger.
  • Keep it thin. If a function adds nothing over goose.Provider, don't wrap it. If the whole package turns out not to justify itself, say so in the PR and propose a documented convention instead.

Done when

  • Tests run against SQLite in-process and against Postgres in CI, and cover:
    • up from empty;
    • up-to and down-to;
    • status;
    • detecting pending migrations;
    • a failing migration leaving a clear error and the correct version;
    • concurrent Up calls on Postgres applying each migration exactly once.
Kickoff prompt
Use the feature-delivery skill to resolve corestack/go#7
(read the issue body; it is the spec). Repo ~/Projects/corestack/go, base main,
branch feat/migrate. Read AGENTS.md and the accepted ADRs first. Clean-room: do not read
or port go-toolkit/migrate. If the page work already added a Postgres CI service, reuse
it. Independent review before the PR.
Root-module package `go.auvem.com/corestack/migrate`. It sets the house convention for SQL migrations on Goose (`github.com/pressly/goose/v3`), using its Provider API. Migrations are embedded in the binary so daemons can migrate at startup. **Clean-room rewrite.** Build from this spec. Don't read or port `go-toolkit/migrate`. ## Requirements - **No dependency on `lifecycle`.** The adapter is a separate issue. - **Construction** takes a `*sql.DB`, a dialect, and an `embed.FS` plus a directory. - **Operations:** up, up-to, down-to, status, and current version. Also "are migrations pending?", so services can refuse to start or report not-ready. - **Concurrent startups.** It must be safe when several replicas or daemons start at once: use Goose's session locker on Postgres, and document the behaviour on other dialects. - **Go-function migrations** are allowed alongside SQL ones. - **Logging** goes through an injected `*slog.Logger`. - **Keep it thin.** If a function adds nothing over `goose.Provider`, don't wrap it. If the whole package turns out not to justify itself, say so in the PR and propose a documented convention instead. ## Done when - Tests run against SQLite in-process and against Postgres in CI, and cover: - up from empty; - up-to and down-to; - status; - detecting pending migrations; - a failing migration leaving a clear error and the correct version; - concurrent `Up` calls on Postgres applying each migration exactly once. <details> <summary>Kickoff prompt</summary> ```text Use the feature-delivery skill to resolve corestack/go#7 (read the issue body; it is the spec). Repo ~/Projects/corestack/go, base main, branch feat/migrate. Read AGENTS.md and the accepted ADRs first. Clean-room: do not read or port go-toolkit/migrate. If the page work already added a Postgres CI service, reuse it. Independent review before the PR. ``` </details>
end added a new dependency 2026-10-26 22:17:23 -07:00
end closed this issue 2026-10-27 23:07:23 -07:00
Sign in to join this conversation.
No labels
1 Participants
Notifications
Due Date
No due date set.
Reference: corestack/go#7