Skip to content

feat(config): assemble Postgres DB from component env vars - #47

Merged
martinemnoble1 merged 1 commit into
mainfrom
feat/db-component-env-vars
Jun 22, 2026
Merged

feat(config): assemble Postgres DB from component env vars#47
martinemnoble1 merged 1 commit into
mainfrom
feat/db-component-env-vars

Conversation

@martinemnoble1

Copy link
Copy Markdown
Owner

What

Adds a component branch to the DB selection in config/settings.py between DATABASE_URL and the SQLite default. When PANDDA_DB_HOST is set, the Postgres config is assembled from PANDDA_DB_* parts so the password arrives as its own env var — a Container App secretRef → Key Vault reference to the existing database-admin-password — instead of being baked into a full-URL secret. No full-URL secret is minted and no credential lands in a file or in az ... show output.

Precedence: DATABASE_URLPANDDA_DB_* (selected by PANDDA_DB_HOST presence) → SQLite.

Vars

var default required
PANDDA_DB_HOST yes (selects branch)
PANDDA_DB_USER yes
PANDDA_DB_PORT 5432 no
PANDDA_DB_NAME reinspect no
PANDDA_DB_PASSWORD "" no
PANDDA_DB_SSLMODE require no

Notes

  • Backward compatible: desktop/SQLite and DATABASE_URL deploys see no change.
  • No new deps: psycopg already present in the image.
  • server_main.py runs migrate on start, so a fresh Postgres self-migrates (tables only — the database must already exist on the server; deployment ensures that).
  • New vars documented in docs/CLOUD_DEPLOYMENT.md.

🤖 Generated with Claude Code

Add a component branch to the DB selection in config/settings.py between
DATABASE_URL and the SQLite default. When PANDDA_DB_HOST is set, build the
Postgres config from PANDDA_DB_* parts so the password arrives as its own
env var (a Container App secretRef -> Key Vault reference) instead of being
baked into a full-URL secret.

Precedence: DATABASE_URL > PANDDA_DB_* > SQLite. Fully backward compatible:
desktop/SQLite and DATABASE_URL deploys are unchanged. No new deps (psycopg
already present). Document the new vars in docs/CLOUD_DEPLOYMENT.md.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@martinemnoble1
martinemnoble1 merged commit a3a84e4 into main Jun 22, 2026
4 checks passed
@martinemnoble1
martinemnoble1 deleted the feat/db-component-env-vars branch June 22, 2026 14:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant