M1/#291: wire Postgres migrations + pgxpool #4
Reference in New Issue
Block a user
Delete Branch "dev"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Summary
First M1 step — replace the stubbed
internal/dbpackage with a real Postgres layer:internal/db/db.go:Open()returns apgxpool.Pool;Migrate()runs embedded migrations viagolang-migrate/v4with thepgx/v5driver (registered schemepgx5).internal/db/migrations/0001_init.{up,down}.sql: placeholder migration to establish the runner. Real schema (artists/albums/tracks/users) lands in 0002 (task #292).cmd/minstrel/main.go: rundb.Migratethendb.Openon startup; deferpool.Close().go.mod/go.sum: addgithub.com/jackc/pgx/v5 v5.7.4,github.com/golang-migrate/migrate/v4 v4.18.2. Pinned to versions that still support thego 1.23toolchain (newer releases require 1.24/1.25).docker-compose.yml: addminstrelservice that depends on healthypostgresand wiresSMARTMUSIC_DATABASE_URL..env.example: documentSMARTMUSIC_*overrides + the opt-inMINSTREL_TEST_DATABASE_URL.internal/db/db_test.go: env-var-gated real-Postgres test (idempotent Migrate +schema_migrationscount). Skipped in-shortmode (CI) and when the env var is unset.Local verification
go vet ./... && gofmt -l .clean.go test -short -race ./...green (CI-equivalent).docker run ... postgres:16-alpine:go test ./... -run TestMigrategreen (both migrations applied idempotently).go run ./cmd/minstrelagainst the local pg → logmigrations applied version=1 dirty=false→curl /healthz→{"status":"ok"}.docker run ... git.fabledsword.com/bvandeusen/runner-base:go-ci bash -c 'golangci-lint run ./... && go test -short -race ./...'green.Test plan
test.ymlpasses on this PRrelease.ymlpublishes updated:mainimageTracks Fable task #291 under milestone 26 (M1 Subsonic baseline).