F-04: DB connection + golang-migrate runner (bookshelf-qqz.4) #7
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "bd-bookshelf-qqz.4"
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
internal/dbpackage withOpen(*sql.DB), connection pool config fromdb.Config, and exponential-backoff retry on ping (max 5 attempts, 30 s cap) to handle compose startup racesinternal/db/migrations/*.sqlviaembed.FSand providesRunMigrations(ctx, db, logger)using golang-migrate with iofs source + mysql database driver; logs completion withduration_ms0001_initcreates_pingtable (up) and drops it (down) — no Grimmory schema yet (that is F-12)Makefilemigrate-up/migrate-downtargets wired to golang-migrate CLITest plan
go vet ./internal/db/...passesgo test -race ./internal/db/...— 12 specs pass (8 integration via testcontainers-go, 4 unit retry/mask/min)go test -coverprofile=coverage.out -coverpkg=./internal/db ./internal/db/...→ 100.0% oninternal/dbCloses bead bookshelf-qqz.4 on merge.
- Remove 0001_init.{up,down}.sql (_ping placeholder) - Add 0001_grimmory_baseline.{up,down}.sql from sanitized Grimmory MariaDB dump * 72 CREATE TABLE statements with collation, timestamp, display-width fixes * SET FOREIGN_KEY_CHECKS=0/1 wrapping (alphabetical order causes forward FK refs) * UNIQUE KEY ... USING HASH on varchar(1000) cfi columns replaced with cfi(764) prefix indexes — utf8mb4*1000=4000 bytes exceeds MySQL 8 InnoDB 3072-byte limit - Update db_test.go: verify 4 representative baseline tables exist instead of _ping Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>bf261d25c0to419b8c0403b7bd10105ae23614cbd5ea9ce85c2e79a16846ab