Skip to content

Commit c7b27f8

Browse files
Lionel-Wilsoncursoragent
authored andcommitted
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>&nbsp;<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>&nbsp;</div> --------- Co-authored-by: Cursor Agent <cursoragent@cursor.com> GitOrigin-RevId: 90f684240aa6e383a3a1daf12e452ee306cb8d1e
1 parent 089103a commit c7b27f8

2 files changed

Lines changed: 14 additions & 15 deletions

File tree

go.mod

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -223,7 +223,7 @@ require (
223223
github.com/GoogleCloudPlatform/opentelemetry-operations-go/detectors/gcp v1.31.0 // indirect
224224
github.com/GoogleCloudPlatform/opentelemetry-operations-go/exporter/metric v0.55.0 // indirect
225225
github.com/GoogleCloudPlatform/opentelemetry-operations-go/internal/resourcemapping v0.55.0 // indirect
226-
github.com/ProtonMail/go-crypto v1.3.0 // indirect
226+
github.com/ProtonMail/go-crypto v1.4.1 // indirect
227227
github.com/PuerkitoBio/rehttp v1.4.0 // indirect
228228
github.com/agext/levenshtein v1.2.3 // indirect
229229
github.com/alecthomas/chroma/v2 v2.16.0 // indirect
@@ -281,7 +281,6 @@ require (
281281
github.com/fsnotify/fsnotify v1.9.0 // indirect
282282
github.com/fxamacker/cbor/v2 v2.9.0 // indirect
283283
github.com/gabriel-vasile/mimetype v1.4.12 // indirect
284-
github.com/go-git/go-git/v5 v5.17.1 // indirect
285284
github.com/go-json-experiment/json v0.0.0-20251027170946-4849db3c2f7e // indirect
286285
github.com/go-logr/logr v1.4.3 // indirect
287286
github.com/go-logr/stdr v1.2.2 // indirect
@@ -320,9 +319,9 @@ require (
320319
github.com/hashicorp/go-multierror v1.1.1 // indirect
321320
github.com/hashicorp/go-plugin v1.7.0 // indirect
322321
github.com/hashicorp/go-uuid v1.0.3 // indirect
323-
github.com/hashicorp/go-version v1.8.0 // indirect
322+
github.com/hashicorp/go-version v1.9.0 // indirect
324323
github.com/hashicorp/golang-lru/v2 v2.0.7 // indirect
325-
github.com/hashicorp/hc-install v0.9.3 // indirect
324+
github.com/hashicorp/hc-install v0.9.4 // indirect
326325
github.com/hashicorp/hcl v1.0.0 // indirect
327326
github.com/hashicorp/logutils v1.0.0 // indirect
328327
github.com/hashicorp/terraform-exec v0.25.0 // indirect
@@ -434,7 +433,7 @@ require (
434433
go.yaml.in/yaml/v2 v2.4.3 // indirect
435434
golang.org/x/crypto v0.50.0 // indirect
436435
golang.org/x/exp v0.0.0-20251023183803-a4bb9ffd2546 // indirect
437-
golang.org/x/mod v0.34.0 // indirect
436+
golang.org/x/mod v0.35.0 // indirect
438437
golang.org/x/sys v0.43.0 // indirect
439438
golang.org/x/telemetry v0.0.0-20260311193753-579e4da9a98c // indirect
440439
golang.org/x/term v0.42.0 // indirect

go.sum

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -169,8 +169,8 @@ github.com/Microsoft/go-winio v0.6.2 h1:F2VQgta7ecxGYO8k3ZZz3RS8fVIXVxONVUPlNERo
169169
github.com/Microsoft/go-winio v0.6.2/go.mod h1:yd8OoFMLzJbo9gZq8j5qaps8bJ9aShtEA8Ipt1oGCvU=
170170
github.com/MrAlias/otel-schema-utils v0.4.0-alpha h1:6ZG9rw4NvxKwRp2Bmnfr8WJZVWLhK4e5n3+ezXE6Z2g=
171171
github.com/MrAlias/otel-schema-utils v0.4.0-alpha/go.mod h1:baehOhES9qiLv9xMcsY6ZQlKLBRR89XVJEvU7Yz3qJk=
172-
github.com/ProtonMail/go-crypto v1.3.0 h1:ILq8+Sf5If5DCpHQp4PbZdS1J7HDFRXz/+xKBiRGFrw=
173-
github.com/ProtonMail/go-crypto v1.3.0/go.mod h1:9whxjD8Rbs29b4XWbB8irEcE8KHMqaR2e7GWU1R+/PE=
172+
github.com/ProtonMail/go-crypto v1.4.1 h1:9RfcZHqEQUvP8RzecWEUafnZVtEvrBVL9BiF67IQOfM=
173+
github.com/ProtonMail/go-crypto v1.4.1/go.mod h1:e1OaTyu5SYVrO9gKOEhTc+5UcXtTUa+P3uLudwcgPqo=
174174
github.com/PuerkitoBio/rehttp v1.4.0 h1:rIN7A2s+O9fmHUM1vUcInvlHj9Ysql4hE+Y0wcl/xk8=
175175
github.com/PuerkitoBio/rehttp v1.4.0/go.mod h1:LUwKPoDbDIA2RL5wYZCNsQ90cx4OJ4AWBmq6KzWZL1s=
176176
github.com/a-h/templ v0.3.1001 h1:yHDTgexACdJttyiyamcTHXr2QkIeVF1MukLy44EAhMY=
@@ -430,8 +430,8 @@ github.com/go-git/gcfg v1.5.1-0.20230307220236-3a3c6141e376 h1:+zs/tPmkDkHx3U66D
430430
github.com/go-git/gcfg v1.5.1-0.20230307220236-3a3c6141e376/go.mod h1:an3vInlBmSxCcxctByoQdvwPiA7DTK7jaaFDBTtu0ic=
431431
github.com/go-git/go-billy/v5 v5.8.0 h1:I8hjc3LbBlXTtVuFNJuwYuMiHvQJDq1AT6u4DwDzZG0=
432432
github.com/go-git/go-billy/v5 v5.8.0/go.mod h1:RpvI/rw4Vr5QA+Z60c6d6LXH0rYJo0uD5SqfmrrheCY=
433-
github.com/go-git/go-git/v5 v5.17.1 h1:WnljyxIzSj9BRRUlnmAU35ohDsjRK0EKmL0evDqi5Jk=
434-
github.com/go-git/go-git/v5 v5.17.1/go.mod h1:pW/VmeqkanRFqR6AljLcs7EA7FbZaN5MQqO7oZADXpo=
433+
github.com/go-git/go-git/v5 v5.18.0 h1:O831KI+0PR51hM2kep6T8k+w0/LIAD490gvqMCvL5hM=
434+
github.com/go-git/go-git/v5 v5.18.0/go.mod h1:pW/VmeqkanRFqR6AljLcs7EA7FbZaN5MQqO7oZADXpo=
435435
github.com/go-jose/go-jose/v4 v4.1.4 h1:moDMcTHmvE6Groj34emNPLs/qtYXRVcd6S7NHbHz3kA=
436436
github.com/go-jose/go-jose/v4 v4.1.4/go.mod h1:x4oUasVrzR7071A4TnHLGSPpNOm2a21K9Kf04k1rs08=
437437
github.com/go-json-experiment/json v0.0.0-20251027170946-4849db3c2f7e h1:Lf/gRkoycfOBPa42vU2bbgPurFong6zXeFtPoxholzU=
@@ -555,12 +555,12 @@ github.com/hashicorp/go-retryablehttp v0.7.8/go.mod h1:rjiScheydd+CxvumBsIrFKlx3
555555
github.com/hashicorp/go-uuid v1.0.0/go.mod h1:6SBZvOh/SIDV7/2o3Jml5SYk/TvGqwFJ/bN7x4byOro=
556556
github.com/hashicorp/go-uuid v1.0.3 h1:2gKiV6YVmrJ1i2CKKa9obLvRieoRGviZFL26PcT/Co8=
557557
github.com/hashicorp/go-uuid v1.0.3/go.mod h1:6SBZvOh/SIDV7/2o3Jml5SYk/TvGqwFJ/bN7x4byOro=
558-
github.com/hashicorp/go-version v1.8.0 h1:KAkNb1HAiZd1ukkxDFGmokVZe1Xy9HG6NUp+bPle2i4=
559-
github.com/hashicorp/go-version v1.8.0/go.mod h1:fltr4n8CU8Ke44wwGCBoEymUuxUHl09ZGVZPK5anwXA=
558+
github.com/hashicorp/go-version v1.9.0 h1:CeOIz6k+LoN3qX9Z0tyQrPtiB1DFYRPfCIBtaXPSCnA=
559+
github.com/hashicorp/go-version v1.9.0/go.mod h1:fltr4n8CU8Ke44wwGCBoEymUuxUHl09ZGVZPK5anwXA=
560560
github.com/hashicorp/golang-lru/v2 v2.0.7 h1:a+bsQ5rvGLjzHuww6tVxozPZFVghXaHOwFs4luLUK2k=
561561
github.com/hashicorp/golang-lru/v2 v2.0.7/go.mod h1:QeFd9opnmA6QUJc5vARoKUSoFhyfM2/ZepoAG6RGpeM=
562-
github.com/hashicorp/hc-install v0.9.3 h1:1H4dgmgzxEVwT6E/d/vIL5ORGVKz9twRwDw+qA5Hyho=
563-
github.com/hashicorp/hc-install v0.9.3/go.mod h1:FQlQ5I3I/X409N/J1U4pPeQQz1R3BoV0IysB7aiaQE0=
562+
github.com/hashicorp/hc-install v0.9.4 h1:KKWOpUG0EqIV63Qk2GGFrZ0s275NVs5lKf9N5vjBNoc=
563+
github.com/hashicorp/hc-install v0.9.4/go.mod h1:4LRYeEN2bMIFfIv57ldMWt9awfuZhvpbRt0vWmv51WU=
564564
github.com/hashicorp/hcl v1.0.0 h1:0Anlzjpi4vEasTeNFn2mLJgTSwt0+6sfsiTG8qcWGx4=
565565
github.com/hashicorp/hcl v1.0.0/go.mod h1:E5yfLk+7swimpb2L/Alb/PJmXilQ/rhwaUYs4T20WEQ=
566566
github.com/hashicorp/hcl/v2 v2.24.0 h1:2QJdZ454DSsYGoaE6QheQZjtKZSUs9Nh2izTWiwQxvE=
@@ -1028,8 +1028,8 @@ golang.org/x/exp v0.0.0-20251023183803-a4bb9ffd2546 h1:mgKeJMpvi0yx/sU5GsxQ7p6s2
10281028
golang.org/x/exp v0.0.0-20251023183803-a4bb9ffd2546/go.mod h1:j/pmGrbnkbPtQfxEe5D0VQhZC6qKbfKifgD0oM7sR70=
10291029
golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4/go.mod h1:jJ57K6gSWd91VN4djpZkiMVwK6gcyfeH4XE8wZrZaV4=
10301030
golang.org/x/mod v0.8.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs=
1031-
golang.org/x/mod v0.34.0 h1:xIHgNUUnW6sYkcM5Jleh05DvLOtwc6RitGHbDk4akRI=
1032-
golang.org/x/mod v0.34.0/go.mod h1:ykgH52iCZe79kzLLMhyCUzhMci+nQj+0XkbXpNYtVjY=
1031+
golang.org/x/mod v0.35.0 h1:Ww1D637e6Pg+Zb2KrWfHQUnH2dQRLBQyAtpr/haaJeM=
1032+
golang.org/x/mod v0.35.0/go.mod h1:+GwiRhIInF8wPm+4AoT6L0FA1QWAad3OMdTRx4tFYlU=
10331033
golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
10341034
golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
10351035
golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg=

0 commit comments

Comments
 (0)