Skip to content

feat: configurable PostgreSQL schema via postgres.schema value#36

Open
ets wants to merge 1 commit intomainfrom
feat/custom-postgres-schema
Open

feat: configurable PostgreSQL schema via postgres.schema value#36
ets wants to merge 1 commit intomainfrom
feat/custom-postgres-schema

Conversation

@ets
Copy link
Copy Markdown
Contributor

@ets ets commented Apr 14, 2026

Summary

  • Adds postgres.schema to values.yaml (default: "public") so operators can target a custom PostgreSQL schema without touching the DSN URL
  • Injects POSTGRES_SCHEMA env var into templates/api.yaml and templates/cmd.yaml so the controlplane reads the configured schema at runtime
  • Parameterizes the hardcoded 'public' schema filter in the REINDEX maintenance CronJob in templates/postgres.yaml
  • Adds test coverage in tests/api_test.yaml and tests/cmd_test.yaml for both the default value and a custom override

Usage

Operators deploying to a custom schema set a single value:

helm upgrade --install qualytics qualytics/qualytics \
  --set postgres.schema=qualytics \
  -f values.yaml

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 suites
  • Verify POSTGRES_SCHEMA env var is present in API and CMD pods after deploy
  • Confirm REINDEX maintenance job targets the correct schema

🤖 Generated with Claude Code

- 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-apps
Copy link
Copy Markdown

greptile-apps Bot commented Apr 14, 2026

Greptile Summary

This PR adds a configurable postgres.schema value (default "public") that is injected as POSTGRES_SCHEMA into the API and CMD deployments, and used to filter the REINDEX maintenance CronJob in postgres.yaml. The change is minimal, well-tested, and fully backward-compatible.

One minor concern: template.values.yaml (the quick-start template) is not updated to document the new field, so operators using that template won't discover the option without reading the full values.yaml.

Confidence Score: 5/5

  • Safe to merge — all findings are P2 style suggestions with no blocking issues.
  • The change is small and targeted, the default preserves backward compatibility, and tests cover both the default and override cases. The only concerns are a direct schema-name interpolation into SQL (low risk since operator-controlled) and a missing trailing newline in a test file — neither blocks merge.
  • charts/qualytics/templates/postgres.yaml — schema name interpolated directly into SQL string without escaping.

Important Files Changed

Filename Overview
charts/qualytics/values.yaml Adds postgres.schema: "public" with a clear comment; default preserves backward compatibility.
charts/qualytics/templates/api.yaml Injects POSTGRES_SCHEMA env var using `
charts/qualytics/templates/cmd.yaml Mirrors api.yaml change; injects POSTGRES_SCHEMA correctly with `
charts/qualytics/templates/postgres.yaml Parameterizes hardcoded 'public' in REINDEX CronJob SQL, but the schema name is interpolated directly into a SQL string literal without escaping or validation — a schema name with a single quote would produce invalid SQL.
charts/qualytics/tests/api_test.yaml Adds two correct test cases for default and custom schema; missing trailing newline at end of file.
charts/qualytics/tests/cmd_test.yaml Mirrors api_test.yaml additions; tests are correct and include proper documentIndex assertions.

Flowchart

%%{init: {'theme': 'neutral'}}%%
flowchart TD
    A["values.yaml\npostgres.schema: &quot;public&quot;"] --> 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"]
Loading

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 }}';")
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 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.

Suggested change
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
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 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.

Suggested change
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!

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