Skip to content

Phase 2-1: database dual-backend foundation#11

Merged
nbenn merged 4 commits intomainfrom
feat/phase-2-1
Mar 20, 2026
Merged

Phase 2-1: database dual-backend foundation#11
nbenn merged 4 commits intomainfrom
feat/phase-2-1

Conversation

@nbenn
Copy link
Member

@nbenn nbenn commented Mar 19, 2026

Summary

  • Migrate database layer from raw database/sql + inline DDL to sqlx + golang-migrate, supporting both SQLite and PostgreSQL as a config option
  • Add versioned migration files, dialect-aware query rebinding, struct scanning, and IsUniqueConstraintError helper
  • Add PostgreSQL service to CI and devcontainer, with eachDB test helper that runs all DB tests against both backends
  • Add config validation tests for driver selection and env var overrides
  • Add CI branch name validation job; remove merge_group trigger from ci.yml (handled by merge.yml)
  • Update phase 2-1 design doc to match implementation

@codecov
Copy link

codecov bot commented Mar 19, 2026

Codecov Report

❌ Patch coverage is 84.72906% with 31 lines in your changes missing coverage. Please review.
✅ Project coverage is 81.28%. Comparing base (f032f26) to head (41deb15).
⚠️ Report is 10 commits behind head on main.

Files with missing lines Patch % Lines
internal/db/db.go 83.06% 17 Missing and 14 partials ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main      #11      +/-   ##
==========================================
- Coverage   81.35%   81.28%   -0.07%     
==========================================
  Files          58       59       +1     
  Lines        5761     5772      +11     
==========================================
+ Hits         4687     4692       +5     
- Misses        744      749       +5     
- Partials      330      331       +1     
Flag Coverage Δ
docker 81.28% <84.72%> (-0.07%) ⬇️
idp 81.28% <84.72%> (-0.07%) ⬇️
openbao 81.28% <84.72%> (-0.07%) ⬇️
unit 81.28% <84.72%> (-0.07%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

nbenn added 3 commits March 20, 2026 07:58
Migrate the database layer from raw database/sql + inline DDL to sqlx +
golang-migrate, supporting both SQLite and PostgreSQL as a config option.

- Add sqlx, golang-migrate, and pgx/v5 dependencies
- Extract inline DDL into versioned migration files under
  internal/db/migrations/{sqlite,postgres}/
- Replace *sql.DB with *sqlx.DB, add db struct tags to all row types
- Convert all queries to use Rebind and struct scanning
- Add Dialect enum, Open() dispatch, openSQLite/openPostgres paths
- Add IsUniqueConstraintError dialect helper
- Expand DatabaseConfig with driver and url fields, add validation
- Add config tests for driver validation and env var overrides
- Add eachDB test helper to run all DB tests against both backends
- Add PostgreSQL service to CI and devcontainer (docker-compose)
- Update design doc to match implementation
Docker client v28.3.3 deprecated ImageInspectWithRaw in favor of
ImageInspect. Fixes golangci-lint staticcheck SA1019 failure.
pgx cannot encode Go bool into PostgreSQL INTEGER columns. Convert
bool to 0/1 explicitly before passing to the query.
@nbenn nbenn force-pushed the feat/phase-2-1 branch 3 times, most recently from 236a96a to 719a506 Compare March 20, 2026 08:16
@nbenn nbenn enabled auto-merge March 20, 2026 08:18
@nbenn nbenn added this pull request to the merge queue Mar 20, 2026
Merged via the queue into main with commit ee839a2 Mar 20, 2026
10 checks passed
@nbenn nbenn deleted the feat/phase-2-1 branch March 20, 2026 08:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

1 participant