Repository navigation
Description
What happened
External repository review at commit c7bebd1 found a three-way disagreement between the production deployment artefacts. Static read, not reproduced against a live Azure deploy.
| Artefact | Database name | Owner | Reference |
|---|---|---|---|
infra/terraform-prod/main.tf L232–278 |
te_prod |
pgadmin |
— |
build/deploy_all.sh L69–108 (deployer) |
te_mgmt_prod |
postgres |
— |
infra/entrypoint.sh L33–39 |
expects env_prod.sql |
— | — |
Also: a freshly built migration image contains only the committed example launchers. The entrypoint expects a concrete env_prod.sql that nothing in the image generates. A clean image can therefore fail before deployment, even before the name mismatch comes into play.
Why this matters
Two separate problems:
- Clean-image failure. A fresh production image (first deploy, or disaster-recovery rebuild) cannot start because
env_prod.sqlis absent and nothing generates it. - Config drift between IaC and runtime. Terraform creates
te_prodowned bypgadmin. Deployer useste_mgmt_prodowned bypostgres. Running both against a fresh server leaves either two databases, a missing one, or an owner mismatch depending on order.
No production deployment exists yet (#31, #32, #34 all open on Azure setup / cert errors), so nothing is broken today. The hazard is: when Azure plumbing is resolved and the first deploy runs, this breaks before the service starts, with a cryptic entrypoint error.
Decision taken 3 Nov 2026
Fix all three artefacts together in one PR, with a fresh-image fresh-server test as evidence. Splitting the fix leaves the system individually broken at each intermediate state. Must land before Azure plumbing (#31, #32, #34) resumes, so the first production deploy doesn't hit it.
Sub-decision still open: canonical name
Needs the product owner's call before the fix lands:
- (a)
te_prodowned bypgadmin— match Terraform-as-source-of-truth, standard IaC convention - (b)
te_mgmt_prodowned bypostgres— match the deployer, keeps whatever intent "mgmt" was conveying
Running the app as postgres (superuser) is poor practice regardless; if the real intent was "deployer creates DB as postgres, then grants to pgadmin", option (a) with a grant step is the right shape.
Proposed
Three parts in one PR:
- Choose canonical name (sub-decision above).
- Make the entrypoint self-sufficient. Preferred approaches:
- Generate
env_prod.sqlat runtime from a template committed to the image - OR make the entrypoint tolerant of its absence and generate from connection env vars
- NOT: commit a populated
env_prod.sqlto the image, as that risks baking secrets (see RV-S4 / #G37)
- Generate
- Align Terraform, deployer and entrypoint on the chosen name and owner.
Done when
- One canonical name and owner across all three artefacts, referenced in
DECISIONS/<date>-prod-db-naming.md. - Fresh-image fresh-server verification: build image from a clean checkout, run against a PostgreSQL server with no pre-existing
pgadminorpostgresrole beyond the superuser, confirm clean startup. - The verification is recorded on the PR with the exact command and its output.
- CI replica run quoted on the PR (counts in passed / failed / skipped form).
Reference
Tracker row G34 (main tab). Repo review finding RV-S1. Related: G37 (RV-S4 secrets in image), G36 (RV-S3 shared role across environments) — all Standards P1 touching deployment safety. Blocks: nothing today; must land before Azure plumbing (#31, #32, #34) resumes.
Activity
fix: align the production database across Terraform, deployer and ent…
test: run the #172 shell tests under Git Bash on Windows
Merge main into #195/#172/#184 branch
Merge main into #195/#172/#184 branch (picks up #215)
Merge main into #195/#172/#184 branch (picks up #221 and #222) and pl…
Merge main into #195/#172/#184 branch (picks up #225)
Merge pull request #213 from amar-python/claude/csv-loading-postgres-…
test: steadier browser tests; matrix updated for M5-M7 and #229