Repository navigation
TML-2916: un-namespaced PG models default to public namespace per ADR 223 - #838
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yml Review profile: CHILL Plan: Pro Run ID: ⛔ Files ignored due to path filters (19)
📒 Files selected for processing (125)
✅ Files skipped from review due to trivial changes (73)
🚧 Files skipped from review as they are similar to previous changes (44)
📝 WalkthroughWalkthroughUn-namespaced models now resolve to ChangesConditional namespace defaults and regenerated artifacts
Estimated code review effort🎯 4 (Complex) | ⏱️ ~60 minutes Possibly related PRs
Suggested reviewers
Poem
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
|
@prisma-next/extension-author-tools
@prisma-next/mongo-runtime
@prisma-next/family-mongo
@prisma-next/sql-runtime
@prisma-next/family-sql
@prisma-next/extension-arktype-json
@prisma-next/middleware-cache
@prisma-next/mongo
@prisma-next/extension-paradedb
@prisma-next/extension-pgvector
@prisma-next/extension-postgis
@prisma-next/postgres
@prisma-next/sql-orm-client
@prisma-next/sqlite
@prisma-next/extension-supabase
@prisma-next/target-mongo
@prisma-next/adapter-mongo
@prisma-next/driver-mongo
@prisma-next/contract
@prisma-next/utils
@prisma-next/config
@prisma-next/errors
@prisma-next/framework-components
@prisma-next/operations
@prisma-next/ts-render
@prisma-next/contract-authoring
@prisma-next/ids
@prisma-next/psl-parser
@prisma-next/psl-printer
@prisma-next/cli
@prisma-next/cli-telemetry
@prisma-next/emitter
@prisma-next/migration-tools
prisma-next
@prisma-next/vite-plugin-contract-emit
@prisma-next/mongo-codec
@prisma-next/mongo-contract
@prisma-next/mongo-value
@prisma-next/mongo-contract-psl
@prisma-next/mongo-contract-ts
@prisma-next/mongo-emitter
@prisma-next/mongo-schema-ir
@prisma-next/mongo-query-ast
@prisma-next/mongo-orm
@prisma-next/mongo-query-builder
@prisma-next/mongo-lowering
@prisma-next/mongo-wire
@prisma-next/sql-contract
@prisma-next/sql-errors
@prisma-next/sql-operations
@prisma-next/sql-schema-ir
@prisma-next/sql-contract-psl
@prisma-next/sql-contract-ts
@prisma-next/sql-contract-emitter
@prisma-next/sql-lane-query-builder
@prisma-next/sql-relational-core
@prisma-next/sql-builder
@prisma-next/target-postgres
@prisma-next/target-sqlite
@prisma-next/adapter-postgres
@prisma-next/adapter-sqlite
@prisma-next/driver-postgres
@prisma-next/driver-sqlite
commit: |
size-limit report 📦
|
… 223
The contract authoring pipeline injected an empty `__unbound__` storage
namespace into every Postgres contract, in violation of ADR 223 — which
makes `target.defaultNamespaceId` ("public" for Postgres) the static,
target-owned default. Two sites are guarded on `defaultNamespaceId ===
UNBOUND_NAMESPACE_ID` so only SQLite and Mongo (whose default is the
unbound sentinel) keep the slot:
1. `build-contract.ts` — the `ensureUnboundNamespaceSlot` call site at
the end of `buildSqlContractFromDefinition` (the build path both the
PSL interpreter and the TS DSL converge on).
2. `sql-contract-serializer-base.ts` — `hydrateSqlStorage` previously
re-injected the slot on every deserialize round-trip, defeating the
build-time fix during emit. An `abstract get defaultNamespaceId():
string` was added to the base class and implemented in the PG, SQLite,
and Mongo (`SqlContractSerializer` fallback) subclasses.
Regenerates the affected fixtures and baked extension-pack contracts
(pgvector, paradedb, postgis, supabase, audit, feature-flags) to drop
the spurious `__unbound__` slot. Updates the contract-builder.namespaces
tests that encoded the bug as expected behavior. Adds an IR-level test
in interpreter.namespaces that pins the un-namespaced PG → public
invariant end-to-end.
The diamond fixture chain under examples/prisma-next-demo/fixtures/* is
not regenerated by this PR: it has no per-step contract.prisma source
so the regen script cannot rebuild it, and a `grep` of the codebase
shows zero consumers. Left stale; follow-up to add a regen mechanism.
Extends `regen-extension-migrations.mjs` to cover the
multi-extension-monorepo sub-extension packages (audit, feature-flags)
that also carry on-disk migrations + head refs.
Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
Signed-off-by: willbot <[email protected]>
Signed-off-by: Will Madden <[email protected]>
…struction declarations - postgres-contract-serializer.test.ts: RegistryDispatchProbeSerializer needs to implement the new abstract defaultNamespaceId getter. - skills/upgrade + skills/extension-author 0.13-to-0.14/instructions.md: add TML-2916 incidental-substrate-diff markers so per-pr-declaration CI gate sees the upgrade-instruction files were touched. Signed-off-by: willbot <[email protected]> Signed-off-by: Will Madden <[email protected]>
…-2918 Post-rebase regen: TML-2918 (#837) landed schema-qualified op ids (`column.${schema}.${table}.${column}`) for the PG AddColumn op. The prisma-next-demo migration ops.json files now carry `column.public.*` ids; migrationHash updates accordingly. Signed-off-by: willbot <[email protected]> Signed-off-by: Will Madden <[email protected]>
85695a1 to
99d8dc6
Compare
Main shipped the 0.14.0 publish bump (#843) and several follow-ups (TML-2916 #838, TML-2503 #839, TML-2787 #683, TML-2893 #849, ci-fix #847) while slice 1 was in review. Merge to pick them up. Resolution: - `skills/extension-author/.../0.13-to-0.14/instructions.md` — union of the slice's TML-2919 entry and main's TML-2916 entry as two distinct HTML-comment blocks, matching the file's per-ticket convention. Per the skill spec's rebase scenario (lines 122-130): existing entries in the just-shipped 0.13-to-0.14 directory may stay in place; we do not relocate the TML-2919 entry to 0.14-to-0.15. - Lockfile + example fixtures + apps + all other non-slice files — take main's side cleanly (the branch hadn't touched them; auto-merge resolved to main's content). `pnpm install` confirms the lockfile is consistent. - No `src/` conflicts — only the one instructions.md conflict above. Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]> Signed-off-by: willbot <[email protected]> Signed-off-by: Will Madden <[email protected]>
…substrate; delete workspace (prisma#867) ## Linked issue Close-out of [Marker/ledger via typed query AST](https://linear.app/prisma-company/project/markerledger-via-typed-query-ast-dc62ab25d151). Phase-2 op porting + the project's deferred ADR migrate into the new project [Typed DDL migration ops — complete the conversion](https://linear.app/prisma-company/project/typed-ddl-migration-ops-complete-the-conversion-9a86e44d4c38) (TML-2919/2920/2921/2922/2923/2925/2927/2866). ## At a glance ``` 137 files changed, 9067 deletions(-) ``` Removes `projects/migrate-marker-ledger-to-typed-query-ast-commands/` after the final retro, and migrates the durable design notes (the seven design principles, the DDL visitor + dispatch model, the table-level constraint shape, the codec-handling split, the planner-lowering mechanism, the Mongo runner-boundary lowering) into the successor project's workspace as draft material for **TML-2923**'s ADR. No source-code changes. External-reference scan was clean before the delete. The design notes land at [`projects/typed-ddl-migration-ops/typed-ddl-design-notes.md`](projects/typed-ddl-migration-ops/typed-ddl-design-notes.md) — the workspace of the successor "Typed DDL migration ops" project, whose `spec.md`/`plan.md` arrive on `main` with PR [prisma#840](prisma#840) (in flight). The notes are voice-rewritten to strip the project-shaping framing (the close-out workflow's Step 4.5 disposition) and banner-marked as draft-for-TML-2923 — its ADR slice absorbs/replaces this file when it lands. ## Decision Project closes; workspace is deleted. The project's DoD is met or explicitly-deferred-with-ticket: 1. All 11 slices merged. 2. Final retro recorded (commit `36279033f` immediately preceding the delete). 3. Long-lived methodology — the seven design principles + the DDL-as-target-contributed-AST model + the table-constraint shape + codec-handling split + planner lowering mechanism — migrated to the successor project's workspace as draft material that TML-2923's ADR absorbs. The canonical ADR ("DDL as a target-contributed query-AST kind + adapter DDL-lowering seam") + Adapters & Targets / Migration System subsystem-doc updates are owned by TML-2923 in the successor project, where the dust from Phase-2's remaining design decisions has to settle first. 4. No external references to the project dir; nothing to re-point or remove. ## Project DoD verification (acceptance criteria in [spec.md](https://github.com/prisma/prisma-next/blob/fbcda64af/projects/migrate-marker-ledger-to-typed-query-ast-commands/spec.md)) | AC | Status | Evidence | |---|---|---| | Team-DoD floor | ✅ met | repo-wide gates green on every merged slice; Linear close-out via this PR; ADR audit covered by AC prisma#9 (deferred) | | SQL query AST represents `CREATE TABLE` + `CREATE SCHEMA` as target-contributed nodes | ✅ met | Slice 1 (TML-2761, foundational) — merged | | All in-scope marker/ledger ops execute via `adapter.lower()` → driver; zero `db.collection()` in `marker-ledger.ts` | ✅ met | Slice 2 (TML-2753 SQL) + Slice 3 (TML-2825 Mongo) — both merged | | Each family's marker CRUD behind one control-adapter SPI; duplicate read paths + `parseContractMarkerRow` + raw-SQL write builders collapsed | ✅ met | TML-2753 outcome (sql-marker-ops-through-adapter) | | `SqlControlAdapter` exposes marker-write methods symmetric with `MongoControlAdapter` | ✅ met | TML-2753 | | Contract-free construction surface per family; no in-scope op hand-builds nodes by object literal or concatenates raw SQL | ✅ met | TML-2761 (SQL DDL surface) + TML-2825 corrective round 2 (Mongo). Phase-2 op-porting tracked by TML-2919/2920/2921/2922 in the successor project. | | Two `as` casts in Mongo `marker-ledger.ts` eliminated; cast ratchet not regressed | ✅ met | TML-2825 | | Invariant-merge converges on accumulate-dedupe across PG + SQLite; test pins for both dialects | ✅ met | TML-2753 | | Migration planner adopts typed AST across all three targets (or residual deferred with tracked follow-ups) | ✅ met | Phase 1 closed: Slice 5 SQLite ([prisma#768](prisma#768) / TML-2859), Slice 7 PG ALTER ([prisma#813](prisma#813)), Slice 6 Mongo ([prisma#816](prisma#816) / TML-2888). Residual op-porting deferred to the successor project. | | ADR "DDL as a target-contributed query-AST kind + adapter DDL-lowering seam" + subsystem-doc updates (Adapters & Targets, Migration System) | 🟡 partially met | Durable design notes migrated to [`projects/typed-ddl-migration-ops/typed-ddl-design-notes.md`](projects/typed-ddl-migration-ops/typed-ddl-design-notes.md) as draft material; canonical ADR + subsystem-doc updates owned by **TML-2923** in the successor project, where the dust from Phase-2's remaining design decisions has to settle first. | ## Slices merged in this project | Slice | Linear | PR | |---|---|---| | `ddl-in-query-ast` (foundational) | TML-2761 | merged | | `sql-marker-ops-through-adapter` | TML-2753 | merged | | `mongo-marker-ledger-through-adapter` | TML-2825 | merged | | `planner-create-table-adopts-ddl-ast` | TML-2754 | [prisma#751](prisma#751) | | `codec-routed-ddl-defaults` | TML-2867 | [prisma#794](prisma#794) | | `sqlite-create-table-adoption` (Phase 1) | TML-2859 | [prisma#768](prisma#768) | | `pg-add-column-pioneer` (Phase 1) | — | [prisma#813](prisma#813) | | `mongo-planner-create-collection-and-index-adoption` (Phase 1) | TML-2888 | [prisma#816](prisma#816) | | `typed-migration-verification-queries` | TML-2889 | [prisma#825](prisma#825) | | `un-namespaced-pg-defaults-to-public` | TML-2916 | [prisma#838](prisma#838) | | `pg-addcolumn-opid-and-codecref-roundtrip` | TML-2918 | [prisma#837](prisma#837) | ## What follows in the successor project [Typed DDL migration ops — complete the conversion](https://linear.app/prisma-company/project/typed-ddl-migration-ops-complete-the-conversion-9a86e44d4c38) owns: - **TML-2919** (in flight as [prisma#840](prisma#840)) — PG: remaining raw-SQL op-builders → typed DDL; delete `buildAddColumnSql`. - **TML-2920** — PG: model `CREATE EXTENSION` as first-class entity kind. - **TML-2921** — SQLite: convert op execute steps to typed DDL. - **TML-2922** — SQLite: `RecreateTable` + AST growth (`CASE WHEN`, row-tuple `IN`). - **TML-2866** — SQLite inline-autoincrement: stop smuggling column options through `DdlColumn.type`. - **TML-2923** — ADR + subsystem docs (the deferred AC prisma#10 from this project). - **TML-2925** — Rewrite `dataTransform` op factory: defer lowering, type the EXISTS wrapper. - **TML-2927** — Introduce `PostgresTableRef` end-to-end (typed table refs). ## Reviewer notes - **Deletion is the only behavioral change** — 56 files removed, 5087 deletions, zero additions outside the final retro. Source code, fixtures, examples, and tests are untouched. - **External-reference scan was empty** before delete (`rg -l "projects/migrate-marker-ledger-to-typed-query-ast-commands/" --glob '!projects/migrate-marker-ledger-to-typed-query-ast-commands/**' --glob '!.git/**'` returned no matches). No links to re-point. - **The two commits are intentionally split** (`docs(marker-ledger): final close-out retro` then `chore: close out … — delete workspace`) so the final retro is preserved as a tracked commit on `main` for archeology if anyone later asks "how did Phase 2 get extracted out cleanly?" - **The migrated doc is *draft material*, not a finished ADR.** The design notes capture the steady-state architecture (the principles, the visitor/dispatch model, the constraint shape, the codec split, the lowering mechanism); they live in the successor project's workspace alongside its `spec.md`/`plan.md`, where TML-2923's ADR slice absorbs/replaces it. Writing the canonical ADR here, before the remaining Phase-2 design decisions (TML-2919/2920/2921/2922) land, would produce a doc that drifts within weeks. - **The doc lands on `main` before the successor project's workspace does** (TML-2919/prisma#840 also creates `projects/typed-ddl-migration-ops/` but is in flight). If this PR merges first, my commit creates the dir; if prisma#840 merges first, my file lands next to its spec/plan. Either order works. ## Testing performed - Worktree gates not re-run for a delete-only PR; the merged slices each shipped with their own gate runs. - `rg` reference scan confirmed pre-delete. ## Skill update n/a — internal project workspace removal. ## Checklist - [x] All commits signed off (DCO). - [x] Scoped to one logical concern (project close-out). - [x] Tests are updated — `n/a` (delete-only, no behavioral change). - [x] PR title in `<TICKET-or-scope>: <sentence-case title>` form. - [x] **Skill update** filled in (`n/a`). --------- Signed-off-by: willbot <[email protected]> Signed-off-by: Will Madden <[email protected]> Co-authored-by: Claude Sonnet 4.6 <[email protected]>
At a glance
Postgres contracts were emitting an empty
__unbound__storage namespace slot alongsidepublicon every contract — in violation of ADR 223 — Target-owned default namespace, which makestarget.defaultNamespaceId(="public"for Postgres) the static, target-owned default. Surfaced during the #825 (TML-2889) review.The decision
Two sites in the authoring/emit pipeline injected the spurious slot. Both are now gated on
defaultNamespaceId === UNBOUND_NAMESPACE_ID— descriptor-driven, notargetId === 'postgres'branch anywhere (per ADR 223). Only SQLite and Mongo (whose default IS unbound) keep the slot.packages/2-sql/2-authoring/contract-ts/src/build-contract.ts:748— end ofbuildSqlContractFromDefinition, the path both the PSL interpreter and the TS DSL converge onensureUnboundNamespaceSlotcall ondefaultNamespaceId === UNBOUND_NAMESPACE_ID.packages/2-sql/9-family/src/core/ir/sql-contract-serializer-base.ts—hydrateSqlStoragere-injected the slot on every deserialize round-trip, defeating site 1 during emitprotected abstract get defaultNamespaceId(): stringtoSqlContractSerializerBase; implemented in PG, SQLite, and theSqlContractSerializerfamily-level fallback (which preserves legacy behaviour for callers without a target descriptor). Mongo uses its own base class and is unaffected.Why two sites
D1 (diagnosis dispatch) identified site 1 only; the in-memory contract built via the TS DSL was already clean (only
public). D2's emit traced throughexecuteContractEmit→familyInstance.deserializeContract(enrichedIR)→hydrateSqlStorage, where the round-trip re-introduced the slot. Sites 1 and 2 are independent; both need the gate.What's regenerated
src/contract.json+.d.tslose the__unbound__slot; their migrationhead.jsonrefs andmigration.tshashes are rewritten bymigrations:regen.scripts/regen-extension-migrations.mjswas extended to walk these (they live underexamples/multi-extension-monorepo/packages/*, outside the script's originalpackages/3-extensions/walk).apps/telemetry-backend,examples/{bundle-size, paradedb-demo, prisma-next-cloudflare-worker, multi-extension-monorepo/app, prisma-next-demo, prisma-next-postgis-demo}— emitted contracts + migration chains lose the slot; migration hashes update.packages/2-sql/4-lanes/sql-builder/test/fixtures/generated/,packages/3-extensions/sql-orm-client/test/fixtures/generated/,test/e2e/framework/test/fixtures/generated/,test/integration/test/{fixtures,namespaced-accessors/fixtures/generated}/— same.What was NOT regenerated
The diamond + 6 sibling fixture chains under
examples/prisma-next-demo/fixtures/*/migrations/app/. The regen script (regen-example-migrations.mjs) requires a per-stepcontract.prismafor each migration directory to recompute the end-state contract; these chains store onlymigration.tsper step plus a single rootcontract.prismafor the final state. Agrep -rln "fixtures/diamond"(excludingnode_modules,dist,.json,.d.ts) returns zero hits outside the slice's own docs — no test or script reads these fixtures. Left stale on this branch; follow-up to add a regen mechanism or rewrite them.Tests
packages/2-sql/2-authoring/contract-psl/test/interpreter.namespaces.test.ts— a baremodel user { id String @id }interpreted against the PG target producesdomain.namespaces.public.models.user+storage.namespaces.public, with no__unbound__namespace. Goes red onmainwithout the fix at site 1.packages/2-sql/2-authoring/contract-ts/test/contract-builder.namespaces.test.tsthat asserted__unbound__was present in PG storage — flipped to assert post-fix shape with a// TML-2916marker.packages/3-extensions/pgvector/test/descriptor.test.ts:100asserted the install-vector pre/postcheck SQL contained literalextname = 'vector'. The regen produces parameterised SQL ("extname" = \$1+params: ["vector"]), a downstream effect of TML-2889's typed-AST routing of verification queries. Test updated to assert both the parameter placeholder and the params array.ADR-223 grep gate
Returns the same 3 hits as before — all input validation guards rejecting reserved namespace names. No new namespace-defaulting branches.
Related
MigrationPG methods require explicitschema). This PR is the planner/interpreter half.Closes TML-2916.
Summary by CodeRabbit
Release Notes
Refactor
publicnamespace where applicable.Chores
Tests
Documentation