feat: add pg-schema-diff namespace FK PoC - #4903
Conversation
|
Important Review skippedDraft detected. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Plus Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
2 Open source vulnerabilities detected - critical severity
Aikido detected 2 vulnerabilities across 2 packages, it includes 1 critical and 1 high vulnerabilities.
Details
Remediation:
github.com/jackc/pgx/v4— 1 CVE (critical) — no fix version availablegithub.com/jackc/pgproto3/v2— 1 CVE (high) — no fix version available
Reply @AikidoSec ignore: [REASON] to ignore this issue.
More info
Summary
pg-schema-difflibrary command that compares migration history with Ent, the namespace-FK overlay, and Ent-managed views in disposable databasespublicschema qualification or theschema_omstate tableWhy
Existing ID-only foreign keys do not enforce that the referencing and referenced rows belong to the same namespace. This allowed billing configuration to reference resources from another namespace. The POC explores an open-source workflow for deriving additive
(namespace, foreign_id) -> (namespace, id)constraints without Atlas Pro.POC limitations
atlas.sumValidation
make check-namespace-fksgo test ./tools/migrate/pgschemadiff ./tools/migrate/cmd/pgschemadiff ./tools/migrate/viewgen ./tools/migrate/namespacefks ./tools/migrate/cmd/namespacefksdirenv exec . make lint-go-fastPG_SCHEMA_DIFF_OUTPUT=/tmp/openmeter-pgschema-diff-pr.sql direnv exec . make pgschema-diff-pocpublicschema qualification,schema_om, existing check constraints, or spurious table creationGreptile Summary
The PR adds a proof-of-concept migration workflow that derives namespace-aware composite foreign keys from Ent metadata and uses disposable PostgreSQL databases to compare migration history with the desired schema.
Confidence Score: 5/5
The PR appears safe to merge, with no concrete blocking or independently actionable non-blocking defects identified.
The generated namespace constraints preserve existing relationship lifecycle behavior, and the schema-diff workflow operates on disposable databases with replay validation before rendering its review-only SQL.
Important Files Changed
Flowchart
%%{init: {'theme': 'neutral'}}%% flowchart LR M[Migration history] --> C[Current disposable database] M --> D[Desired disposable database] E[Ent schema] --> D F[Generated namespace FKs] --> D V[Ent-managed views] --> D C --> P[pg-schema-diff plan] D --> P P --> R[Replay validation] R --> S[Migration-style SQL]Reviews (1): Last reviewed commit: "feat: add pg-schema-diff namespace FK Po..." | Re-trigger Greptile
Context used: