feat: configurable PostgreSQL schema via postgres.schema value#36
feat: configurable PostgreSQL schema via postgres.schema value#36
Conversation
- Add postgres.schema to values.yaml (default: "public") for custom schema support - Inject POSTGRES_SCHEMA env var into api.yaml and cmd.yaml templates - Parameterize hardcoded 'public' schema filter in REINDEX maintenance CronJob - Add test coverage in api_test.yaml and cmd_test.yaml for default and override cases Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Greptile SummaryThis PR adds a configurable One minor concern: Confidence Score: 5/5
Important Files Changed
Flowchart%%{init: {'theme': 'neutral'}}%%
flowchart TD
A["values.yaml\npostgres.schema: "public""] --> B["Helm template rendering"]
B --> C["api.yaml\nPOSTGRES_SCHEMA env var"]
B --> D["cmd.yaml\nPOSTGRES_SCHEMA env var"]
B --> E["postgres.yaml\nREINDEX CronJob SQL\nWHERE schemaname = 'schema'"]
C --> F["qualytics-api pod\nreads POSTGRES_SCHEMA at runtime"]
D --> G["qualytics-cmd pod\nreads POSTGRES_SCHEMA at runtime"]
E --> H["maintenance-cronjob\ntargets configured schema"]
Reviews (1): Last reviewed commit: "feat: configurable PostgreSQL schema via..." | Re-trigger Greptile |
| SELECT '\"' || schemaname || '\".\"' || tablename || '\"' | ||
| FROM pg_tables | ||
| WHERE schemaname = 'public';") | ||
| WHERE schemaname = '{{ .Values.postgres.schema }}';") |
There was a problem hiding this comment.
Schema value interpolated directly into SQL string
The schema name is embedded via string interpolation inside single quotes. A name containing a single quote (e.g., my'schema) would produce invalid SQL, and a deliberately crafted value could rewrite the query. While this is an operator-supplied value, parameterizing or regex-validating the name (e.g., ^[a-zA-Z_][a-zA-Z0-9_]*$) is safer.
| WHERE schemaname = '{{ .Values.postgres.schema }}';") | |
| WHERE schemaname = $1;" -- -v SCHEMA='{{ .Values.postgres.schema }}' |
Alternatively, add a Helm fail guard in values.yaml or a _helpers.tpl helper that rejects schema names containing characters outside [a-zA-Z0-9_].
| content: | ||
| name: POSTGRES_SCHEMA | ||
| value: "qualytics" | ||
| documentIndex: 0 No newline at end of file |
There was a problem hiding this comment.
Missing newline at end of file
The file is missing a trailing newline (\ No newline at end of file in the diff). POSIX and most linters expect files to end with a newline.
| documentIndex: 0 | |
| documentIndex: 0 |
(add a blank line after this last line)
Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!
Summary
postgres.schematovalues.yaml(default:"public") so operators can target a custom PostgreSQL schema without touching the DSN URLPOSTGRES_SCHEMAenv var intotemplates/api.yamlandtemplates/cmd.yamlso the controlplane reads the configured schema at runtime'public'schema filter in the REINDEX maintenance CronJob intemplates/postgres.yamltests/api_test.yamlandtests/cmd_test.yamlfor both the default value and a custom overrideUsage
Operators deploying to a custom schema set a single value:
No change required for existing deployments — the default remains
"public"for full backward compatibility.Test plan
helm lint charts/qualytics— clean (0 failures)helm unittest charts/qualytics— 198/198 tests passing across 13 suitesPOSTGRES_SCHEMAenv var is present in API and CMD pods after deploy🤖 Generated with Claude Code