Commit c7b27f8
feat: Phase 1 brentdb infrastructure (ENG-3834) (#4763)
<!-- CURSOR_AGENT_PR_BODY_BEGIN -->
## Summary
Provision `brentdb` as Brent's first PostgreSQL database, following
`docs/adding-database-to-new-service.md`. This is Phase 1 of the Plan
Reviews in Brent project — a pure infrastructure phase that unblocks all
downstream phases needing durable state.
The database is empty after this phase. No domain tables are defined —
Phase 5 creates the first migration with Plan/Review tables.
## Changes
### Local Development
- Add `brentdb` service (postgres:16) and volume to docker-compose
- Create `brentdb.env` with local credentials
- Add `BRENT_BACKEND_PG*` environment variables to `op.local.env`
### Service Wiring (dbkit)
- Register database flags via `dbkit.AddDatabaseFlags` in `root.go`
- Populate `dbkit.Config` from Viper in `config.go`
- Add `DbConfig` to `ServerConfig`, `pgxpool.Pool` to `Server`
- Connect to database in `Init()`, close pool in `Stop()`
- Add migrate-on-start in `start.go` before server initialization
### sqlc and Atlas Scaffolding
- Add `sqlc.yaml` with gateway-pattern type overrides
- Create `models/placeholder.sql` (Ping query), `schema.sql`,
`generate.go`
- Create empty `migrations/` directory with `atlas.sum`
- Generate sqlc boilerplate (`db.go`, `models.go`, `placeholder.sql.go`)
### Build Scripts
- `build/reset_database.sh` — drop/recreate DB, apply migrations,
regenerate schema + sqlc
- `build/make_migration.sh` — generate new migration from schema changes
- `build/dbshell.sh` — open psql shell to local database
### CI
- Add `brent-backend-code-gen` job (postgres:16 service, sqlc diff/vet,
Atlas migration checks, go generate, git diff)
- Add `go/dbkit/**` and `go/auth/**` to `brent-backend` path filter
- Add `brent-backend-code-gen` to `ci-gate` needs
### Terraform (Aurora Provisioning)
- Create `brent_backend.tf` with `random_password`, `postgresql_role`,
`postgresql_database`, and `brentdb-config` ConfigMap (DB vars only)
- Add brentdb outputs to `outputs.tf`
- Add `BRENT_BACKEND_PG*` fields to both 1Password items in
`1password.tf`
### Kubernetes
- Add `BRENT_BACKEND_PGPASSWORD` to ExternalSecret
- Add `brentdb-config` configMapRef to deployment envFrom
### Documentation
- Add Persistence section to `brent-backend/README.md`
- Add BUGBOT.md for atlas.sum ordering enforcement
## Key Decisions
- **Database name**: `brentdb` (project plan naming, not
`brentbackenddb`)
- **No pgvector**: plain postgres:16 (no vector-search use case)
- **No migration files**: empty `atlas.sum` only; Phase 5 adds first
migration
- **Separate ConfigMap**: kustomize `configmap.yaml` kept for app
config; Terraform manages a separate `brentdb-config` for DB vars
- **Migrate-on-start**: matches api-server pattern; skipped locally via
`BRENT_BACKEND_STARTUP_SKIP_MIGRATE=true`
<!-- CURSOR_AGENT_PR_BODY_END -->
<div><a
href="https://cursor.com/agents/bc-bbfc332a-c5c6-4de3-91e8-a0003718308b"><picture><source
media="(prefers-color-scheme: dark)"
srcset="https://cursor.com/assets/images/open-in-web-dark.png"><source
media="(prefers-color-scheme: light)"
srcset="https://cursor.com/assets/images/open-in-web-light.png"><img
alt="Open in Web" width="114" height="28"
src="https://cursor.com/assets/images/open-in-web-dark.png"></picture></a> <a
href="https://cursor.com/background-agent?bcId=bc-bbfc332a-c5c6-4de3-91e8-a0003718308b"><picture><source
media="(prefers-color-scheme: dark)"
srcset="https://cursor.com/assets/images/open-in-cursor-dark.png"><source
media="(prefers-color-scheme: light)"
srcset="https://cursor.com/assets/images/open-in-cursor-light.png"><img
alt="Open in Cursor" width="131" height="28"
src="https://cursor.com/assets/images/open-in-cursor-dark.png"></picture></a> </div>
---------
Co-authored-by: Cursor Agent <cursoragent@cursor.com>
GitOrigin-RevId: 90f684240aa6e383a3a1daf12e452ee306cb8d1e1 parent 089103a commit c7b27f8
2 files changed
Lines changed: 14 additions & 15 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
223 | 223 | | |
224 | 224 | | |
225 | 225 | | |
226 | | - | |
| 226 | + | |
227 | 227 | | |
228 | 228 | | |
229 | 229 | | |
| |||
281 | 281 | | |
282 | 282 | | |
283 | 283 | | |
284 | | - | |
285 | 284 | | |
286 | 285 | | |
287 | 286 | | |
| |||
320 | 319 | | |
321 | 320 | | |
322 | 321 | | |
323 | | - | |
| 322 | + | |
324 | 323 | | |
325 | | - | |
| 324 | + | |
326 | 325 | | |
327 | 326 | | |
328 | 327 | | |
| |||
434 | 433 | | |
435 | 434 | | |
436 | 435 | | |
437 | | - | |
| 436 | + | |
438 | 437 | | |
439 | 438 | | |
440 | 439 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
169 | 169 | | |
170 | 170 | | |
171 | 171 | | |
172 | | - | |
173 | | - | |
| 172 | + | |
| 173 | + | |
174 | 174 | | |
175 | 175 | | |
176 | 176 | | |
| |||
430 | 430 | | |
431 | 431 | | |
432 | 432 | | |
433 | | - | |
434 | | - | |
| 433 | + | |
| 434 | + | |
435 | 435 | | |
436 | 436 | | |
437 | 437 | | |
| |||
555 | 555 | | |
556 | 556 | | |
557 | 557 | | |
558 | | - | |
559 | | - | |
| 558 | + | |
| 559 | + | |
560 | 560 | | |
561 | 561 | | |
562 | | - | |
563 | | - | |
| 562 | + | |
| 563 | + | |
564 | 564 | | |
565 | 565 | | |
566 | 566 | | |
| |||
1028 | 1028 | | |
1029 | 1029 | | |
1030 | 1030 | | |
1031 | | - | |
1032 | | - | |
| 1031 | + | |
| 1032 | + | |
1033 | 1033 | | |
1034 | 1034 | | |
1035 | 1035 | | |
| |||
0 commit comments