Skip to content

feat(fixtures): regenerate example-app migration snapshots via fixtures:emit#764

Merged
wmadden merged 5 commits into
mainfrom
tml-2838-add-example-app-migration-regen-to-pnpm-fixturesemit
Jun 8, 2026
Merged

feat(fixtures): regenerate example-app migration snapshots via fixtures:emit#764
wmadden merged 5 commits into
mainfrom
tml-2838-add-example-app-migration-regen-to-pnpm-fixturesemit

Conversation

@wmadden-electric

@wmadden-electric wmadden-electric commented Jun 8, 2026

Copy link
Copy Markdown
Contributor

What & why

Example-app migrations carry on-disk contract snapshots (start-contract.* / end-contract.*) that went stale silently whenever the contract IR shape changed — nothing regenerated them, because pnpm migrations:regen only covered extension migrations. A stale snapshot surfaced only when a test happened to deserialize one and tripped the serializer validator (this is the trap TML-2808 hit on retail-store; its fix was a one-shot transform, explicitly not repeatable).

The root cause was that intermediate migrations had no live source on disk to re-emit from. This PR fixes that directly: give each example-app migration a live, re-emittable source — store the migration's end-state schema as contract.prisma in its directory — then regenerate the snapshots from it with the Prisma Next CLI. It's repeatable for any future shape change with no per-change code, because the emitter always produces current-shape output from schema source.

How to review (most of the diff is mechanical)

86 files, but the reviewable substance is small. The bulk is regenerated {start,end}-contract.* / ops.json / migration.json — output of the new script, not hand-written.

Read these:

  • scripts/regen-example-migrations.mjs — the chain walker. Per migration: emit end-contract.* from contract.prisma via a temp config that reuses the example's real prisma-next.config.ts and overrides only the schema source (so extensions / db / family stay correct by construction), copy predecessor end → successor start, rewrite the migration.ts from:/to: hash literals, re-emit ops.json/migration.json via tsx, biome-format.
  • package.jsonmigrations:regen:examples chained into fixtures:emit (after the per-example emit, so the head emits from a fresh src contract); fixtures:check glob widened to {start,end}-contract.*.
  • .agents/rules/never-hand-edit-contract-fixtures.mdc — the rule's "regenerate via pnpm fixtures:emit" promise is now true for example migrations.
  • The 13 new */contract.prisma sources, and the migration.ts changes (hash literals + two validator refactors + one FK fix — see below).

Scope: the four example apps with app/ chains — retail-store (mongo, 3), mongo-demo (mongo, 2), prisma-next-demo (postgres + pgvector, 6, incl. namespaces/MTI), prisma-next-postgis-demo (postgis, 1). Out of scope: pgvector/postgis seed namespaces (single migration, refs/head.json), multi-extension-monorepo (already covered by the extension regen), and prisma-next-demo/fixtures/* (hand-crafted, no live src).

Two behavioural changes worth a closer look

  • Baseline validators (retail-store 0505_initial, mongo-demo): refactored to load collection validators from end-contract.json instead of hardcoding them, so re-emitted ops match the emitter's current validators (the current emitter adds additionalProperties: false).
  • prisma-next-demo 0720_initial foreign keys now pass an explicit schema: 'public'. Without it, the FK builder emits invalid REFERENCES "undefined"."user" DDL. The explicit schema matches the convention the same example's MTI migration already uses. The underlying builder behaviour (emitting "undefined" when the reference schema is omitted) is a latent framework bug this work exposed — tracked separately, out of scope here.

Verification

  • pnpm fixtures:emit is idempotent (run twice → no diff); after merge pnpm fixtures:check is clean from a fresh tree.
  • fixtures:check now fails on a stale example {start,end}-contract.* and passes again after regen (demonstrated by hand-corrupting a snapshot).
  • Head storageHash and profileHash match a fresh prisma-next contract emit of src for all four examples; each non-head end-contract.json is byte-identical to the next migration's start-contract.json.
  • pnpm test:packages green (9923). Example suites: retail-store 55/55, mongo-demo 35/35, postgis 7 skipped (needs live PostGIS). prisma-next-demo has 2–3 pre-existing PGlite-contention flaky failures (verified against a pre-change baseline; unrelated to this PR and they don't read the snapshots).
  • The reconstructions and the regen mechanism were independently reviewed before this PR.

Refs: TML-2838

🤖 Generated with Claude Code

Summary by CodeRabbit

  • Chores
    • Tightened fixture validation rules and expanded ignored regen config.
    • Regenerated migration contracts and updated type definitions to reflect new schema serialization and namespace shapes.
  • New Features
    • Added MongoDB demo migration with polymorphic Post models (Article/Tutorial) and a partial unique index.
    • Added SQL demo migrations with pgvector embeddings and refined namespace/table mappings.

@wmadden-electric wmadden-electric requested a review from a team as a code owner June 8, 2026 08:46
@coderabbitai

coderabbitai Bot commented Jun 8, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

Important

Review skipped

Review was skipped as selected files did not have any reviewable changes.

💤 Files selected but had no reviewable changes (13)
  • packages/1-framework/3-tooling/cli-telemetry/vitest.config.ts
  • packages/1-framework/3-tooling/cli/vitest.config.ts
  • packages/2-sql/5-runtime/vitest.config.ts
  • packages/3-extensions/postgres/vitest.config.ts
  • packages/3-extensions/supabase/vitest.config.ts
  • packages/3-targets/6-adapters/postgres/vitest.config.ts
  • packages/3-targets/7-drivers/postgres/vitest.config.ts
  • skills/extension-author/prisma-next-extension-upgrade/upgrades/0.12-to-0.13/instructions.md
  • skills/upgrade/prisma-next-upgrade/upgrades/0.12-to-0.13/instructions.md
  • test/e2e/framework/vitest.config.ts
  • test/integration/vitest.config.ts
  • test/integration/vitest.journeys.config.ts
  • test/utils/src/exports/index.ts
⚙️ Run configuration

Configuration used: Path: .coderabbit.yml

Review profile: CHILL

Plan: Pro

Run ID: 0c7650f2-ea77-4500-b549-546c9d259ee3

📥 Commits

Reviewing files that changed from the base of the PR and between da92da8 and 3ee17c1.

📒 Files selected for processing (13)
  • packages/1-framework/3-tooling/cli-telemetry/vitest.config.ts
  • packages/1-framework/3-tooling/cli/vitest.config.ts
  • packages/2-sql/5-runtime/vitest.config.ts
  • packages/3-extensions/postgres/vitest.config.ts
  • packages/3-extensions/supabase/vitest.config.ts
  • packages/3-targets/6-adapters/postgres/vitest.config.ts
  • packages/3-targets/7-drivers/postgres/vitest.config.ts
  • skills/extension-author/prisma-next-extension-upgrade/upgrades/0.12-to-0.13/instructions.md
  • skills/upgrade/prisma-next-upgrade/upgrades/0.12-to-0.13/instructions.md
  • test/e2e/framework/vitest.config.ts
  • test/integration/vitest.config.ts
  • test/integration/vitest.journeys.config.ts
  • test/utils/src/exports/index.ts

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
📝 Walkthrough

Walkthrough

Tightens the "never hand-edit" fixture rule and .gitignore, then regenerates example migration contracts (Mongo and Prisma-next) to a namespace-oriented storage/emit shape, updating emitted JSON/.d.ts, type aliases, index metadata, and migration fingerprints.

Changes

Fixture rules and tooling

Layer / File(s) Summary
Fixture handling rules and ignore updates
.agents/rules/never-hand-edit-contract-fixtures.mdc, .gitignore
Expanded never-hand-edit rule to forbid {start,end}-contract.{json,d.ts}, broadened git status helper globs, and added **/.prisma-next-regen.config.ts to .gitignore (transient regen file).

MongoDB demo contract regeneration

Layer / File(s) Summary
Initial MongoDB migration contract
examples/mongo-demo/migrations/app/20260409T1030_migration/{contract.prisma,end-contract.d.ts,end-contract.json,migration.*}
Adds Address/User/Post (+Article/Tutorial) schema and regenerates contracts to namespace-scoped storage with discriminator oneOf validators, updated hashes and Models alias.
MongoDB posts-author-index migration contract
examples/mongo-demo/migrations/app/20260415_add-posts-author-index/{contract.prisma,end-contract.d.ts,end-contract.json,start-contract.*,migration.*}
Adds posts-summary unique partial index and regenerates start/end contract JSON and typings to express index and discriminator variants in the namespaced storage shape.

Prisma-next demo contract regeneration

Layer / File(s) Summary
Initial Prisma-next migration
examples/prisma-next-demo/migrations/app/20260422T0720_initial/{contract.prisma,end-contract.*,migration.*}
Adds pgvector Embedding1536, Address, user_type, and five models; regenerates contract typings/JSON to namespace-scoped storage with updated hashes, query-op typing, and exported aliases.
Prisma-next migration with displayName field
examples/prisma-next-demo/migrations/app/20260422T0742_migration/{contract.prisma,end-contract.*,start-contract.*,migration.*}
Regenerated contracts use explicit public namespace bindings and parameterized QueryOperationTypes; field output typings (e.g., Post.embedding, User.kind) tightened.
Prisma-next migration with schema-qualified operations
examples/prisma-next-demo/migrations/app/20260422T0748_migration/{contract.prisma,end-contract.*,start-contract.*,migration.*,ops.json}
Ops updated to qualify "public"."user" in SQL; emitted contracts use namespace-scoped storage and updated capability flags.
Prisma-next namespaces bookend migration
examples/prisma-next-demo/migrations/app/20260518T1701_namespaces_bookend/{contract.prisma,end-contract.*,start-contract.*,migration.*,ops.json}
Regenerated contracts introduce explicit __unbound__ + public namespaces and reshape domain/value-object typing.
Prisma-next public namespaces bookend migration
examples/prisma-next-demo/migrations/app/20260605T1143_public_namespaces_bookend/{contract.prisma,end-contract.*,start-contract.*,migration.*,ops.json}
Regenerated contracts remove Task polymorphism, promote Bug/Feature to public roots, and compact JSON formatting in emitted files.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Possibly related PRs

Suggested reviewers

  • aqrln

Poem

🐰 Contracts hopped into neat namespaces,

hashes, types, and indexes in friendly places.
Emitters hummed, no hand-edit fright,
fixtures tidy, every contract just right.
🥕✨

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch tml-2838-add-example-app-migration-regen-to-pnpm-fixturesemit

@github-actions

github-actions Bot commented Jun 8, 2026

Copy link
Copy Markdown

size-limit report 📦

Path Size
postgres / no-emit 149.25 KB (0%)
postgres / emit 118.3 KB (0%)
mongo / no-emit 76.67 KB (0%)
mongo / emit 70.96 KB (0%)
cf-worker / no-emit 179.31 KB (0%)
cf-worker / emit 145.03 KB (0%)

@pkg-pr-new

pkg-pr-new Bot commented Jun 8, 2026

Copy link
Copy Markdown

Open in StackBlitz

@prisma-next/extension-author-tools

npm i https://pkg.pr.new/@prisma-next/extension-author-tools@764

@prisma-next/mongo-runtime

npm i https://pkg.pr.new/@prisma-next/mongo-runtime@764

@prisma-next/family-mongo

npm i https://pkg.pr.new/@prisma-next/family-mongo@764

@prisma-next/sql-runtime

npm i https://pkg.pr.new/@prisma-next/sql-runtime@764

@prisma-next/family-sql

npm i https://pkg.pr.new/@prisma-next/family-sql@764

@prisma-next/extension-arktype-json

npm i https://pkg.pr.new/@prisma-next/extension-arktype-json@764

@prisma-next/middleware-cache

npm i https://pkg.pr.new/@prisma-next/middleware-cache@764

@prisma-next/mongo

npm i https://pkg.pr.new/@prisma-next/mongo@764

@prisma-next/extension-paradedb

npm i https://pkg.pr.new/@prisma-next/extension-paradedb@764

@prisma-next/extension-pgvector

npm i https://pkg.pr.new/@prisma-next/extension-pgvector@764

@prisma-next/extension-postgis

npm i https://pkg.pr.new/@prisma-next/extension-postgis@764

@prisma-next/postgres

npm i https://pkg.pr.new/@prisma-next/postgres@764

@prisma-next/sql-orm-client

npm i https://pkg.pr.new/@prisma-next/sql-orm-client@764

@prisma-next/sqlite

npm i https://pkg.pr.new/@prisma-next/sqlite@764

@prisma-next/extension-supabase

npm i https://pkg.pr.new/@prisma-next/extension-supabase@764

@prisma-next/target-mongo

npm i https://pkg.pr.new/@prisma-next/target-mongo@764

@prisma-next/adapter-mongo

npm i https://pkg.pr.new/@prisma-next/adapter-mongo@764

@prisma-next/driver-mongo

npm i https://pkg.pr.new/@prisma-next/driver-mongo@764

@prisma-next/contract

npm i https://pkg.pr.new/@prisma-next/contract@764

@prisma-next/utils

npm i https://pkg.pr.new/@prisma-next/utils@764

@prisma-next/config

npm i https://pkg.pr.new/@prisma-next/config@764

@prisma-next/errors

npm i https://pkg.pr.new/@prisma-next/errors@764

@prisma-next/framework-components

npm i https://pkg.pr.new/@prisma-next/framework-components@764

@prisma-next/operations

npm i https://pkg.pr.new/@prisma-next/operations@764

@prisma-next/ts-render

npm i https://pkg.pr.new/@prisma-next/ts-render@764

@prisma-next/contract-authoring

npm i https://pkg.pr.new/@prisma-next/contract-authoring@764

@prisma-next/ids

npm i https://pkg.pr.new/@prisma-next/ids@764

@prisma-next/psl-parser

npm i https://pkg.pr.new/@prisma-next/psl-parser@764

@prisma-next/psl-printer

npm i https://pkg.pr.new/@prisma-next/psl-printer@764

@prisma-next/cli

npm i https://pkg.pr.new/@prisma-next/cli@764

@prisma-next/cli-telemetry

npm i https://pkg.pr.new/@prisma-next/cli-telemetry@764

@prisma-next/emitter

npm i https://pkg.pr.new/@prisma-next/emitter@764

@prisma-next/migration-tools

npm i https://pkg.pr.new/@prisma-next/migration-tools@764

prisma-next

npm i https://pkg.pr.new/prisma-next@764

@prisma-next/vite-plugin-contract-emit

npm i https://pkg.pr.new/@prisma-next/vite-plugin-contract-emit@764

@prisma-next/mongo-codec

npm i https://pkg.pr.new/@prisma-next/mongo-codec@764

@prisma-next/mongo-contract

npm i https://pkg.pr.new/@prisma-next/mongo-contract@764

@prisma-next/mongo-value

npm i https://pkg.pr.new/@prisma-next/mongo-value@764

@prisma-next/mongo-contract-psl

npm i https://pkg.pr.new/@prisma-next/mongo-contract-psl@764

@prisma-next/mongo-contract-ts

npm i https://pkg.pr.new/@prisma-next/mongo-contract-ts@764

@prisma-next/mongo-emitter

npm i https://pkg.pr.new/@prisma-next/mongo-emitter@764

@prisma-next/mongo-schema-ir

npm i https://pkg.pr.new/@prisma-next/mongo-schema-ir@764

@prisma-next/mongo-query-ast

npm i https://pkg.pr.new/@prisma-next/mongo-query-ast@764

@prisma-next/mongo-orm

npm i https://pkg.pr.new/@prisma-next/mongo-orm@764

@prisma-next/mongo-query-builder

npm i https://pkg.pr.new/@prisma-next/mongo-query-builder@764

@prisma-next/mongo-lowering

npm i https://pkg.pr.new/@prisma-next/mongo-lowering@764

@prisma-next/mongo-wire

npm i https://pkg.pr.new/@prisma-next/mongo-wire@764

@prisma-next/sql-contract

npm i https://pkg.pr.new/@prisma-next/sql-contract@764

@prisma-next/sql-errors

npm i https://pkg.pr.new/@prisma-next/sql-errors@764

@prisma-next/sql-operations

npm i https://pkg.pr.new/@prisma-next/sql-operations@764

@prisma-next/sql-schema-ir

npm i https://pkg.pr.new/@prisma-next/sql-schema-ir@764

@prisma-next/sql-contract-psl

npm i https://pkg.pr.new/@prisma-next/sql-contract-psl@764

@prisma-next/sql-contract-ts

npm i https://pkg.pr.new/@prisma-next/sql-contract-ts@764

@prisma-next/sql-contract-emitter

npm i https://pkg.pr.new/@prisma-next/sql-contract-emitter@764

@prisma-next/sql-lane-query-builder

npm i https://pkg.pr.new/@prisma-next/sql-lane-query-builder@764

@prisma-next/sql-relational-core

npm i https://pkg.pr.new/@prisma-next/sql-relational-core@764

@prisma-next/sql-builder

npm i https://pkg.pr.new/@prisma-next/sql-builder@764

@prisma-next/target-postgres

npm i https://pkg.pr.new/@prisma-next/target-postgres@764

@prisma-next/target-sqlite

npm i https://pkg.pr.new/@prisma-next/target-sqlite@764

@prisma-next/adapter-postgres

npm i https://pkg.pr.new/@prisma-next/adapter-postgres@764

@prisma-next/adapter-sqlite

npm i https://pkg.pr.new/@prisma-next/adapter-sqlite@764

@prisma-next/driver-postgres

npm i https://pkg.pr.new/@prisma-next/driver-postgres@764

@prisma-next/driver-sqlite

npm i https://pkg.pr.new/@prisma-next/driver-sqlite@764

commit: 3ee17c1

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🧹 Nitpick comments (1)
examples/prisma-next-demo/migrations/app/20260422T0720_initial/contract.prisma (1)

57-69: Bug and Feature intentionally omit primary keys (keyless tables)
examples/prisma-next-demo/migrations/app/20260422T0720_initial/contract.prisma defines Bug and Feature without any @id or @@id, and start-contract.json for the related migrations represents Bug/Feature with fields/storage only (no primaryKey), unlike the keyed models (e.g., User, Post, Task).

  • Consider adding a short comment in the schema explaining the rationale for these keyless models/tables if this is intentional.
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In
`@examples/prisma-next-demo/migrations/app/20260422T0720_initial/contract.prisma`
around lines 57 - 69, The Bug and Feature models in contract.prisma are defined
without primary keys (keyless tables), which can be confusing; add a short
explanatory comment above the model declarations (the model Bug and model
Feature definitions) stating that these are intentionally keyless (e.g.,
read-only logs, denormalized views, or external-managed IDs) and why they lack
`@id/`@@id so future readers and maintainers understand the rationale and the
corresponding start-contract.json representation.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In
`@examples/mongo-demo/migrations/app/20260415_add-posts-author-index/migration.json`:
- Around line 2-3: The migration metadata file migration.json for
20260415_add-posts-author-index incorrectly lists identical "from" and "to"
contract hashes, which hides the index changes added by migration.ts (which
creates posts indexes authorId and { createdAt: -1, authorId: 1 }); investigate
and fix by regenerating the contract hash after applying the migration so the
"to" hash reflects the updated contract (ensure contract.prisma and
end-contract.json reflect the new indexes under
.storage.namespaces.__unbound__.entries.collection.posts.indexes), or update the
contract generation logic to include index changes so migration.json's "from"
and "to" differ appropriately.

---

Nitpick comments:
In
`@examples/prisma-next-demo/migrations/app/20260422T0720_initial/contract.prisma`:
- Around line 57-69: The Bug and Feature models in contract.prisma are defined
without primary keys (keyless tables), which can be confusing; add a short
explanatory comment above the model declarations (the model Bug and model
Feature definitions) stating that these are intentionally keyless (e.g.,
read-only logs, denormalized views, or external-managed IDs) and why they lack
`@id/`@@id so future readers and maintainers understand the rationale and the
corresponding start-contract.json representation.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yml

Review profile: CHILL

Plan: Pro

Run ID: 938b728e-8187-408c-8284-a94c264ec497

📥 Commits

Reviewing files that changed from the base of the PR and between b228c47 and b856861.

📒 Files selected for processing (86)
  • .agents/rules/never-hand-edit-contract-fixtures.mdc
  • .gitignore
  • examples/mongo-demo/migrations/app/20260409T1030_migration/contract.prisma
  • examples/mongo-demo/migrations/app/20260409T1030_migration/end-contract.d.ts
  • examples/mongo-demo/migrations/app/20260409T1030_migration/end-contract.json
  • examples/mongo-demo/migrations/app/20260409T1030_migration/migration.json
  • examples/mongo-demo/migrations/app/20260409T1030_migration/migration.ts
  • examples/mongo-demo/migrations/app/20260415_add-posts-author-index/contract.prisma
  • examples/mongo-demo/migrations/app/20260415_add-posts-author-index/end-contract.d.ts
  • examples/mongo-demo/migrations/app/20260415_add-posts-author-index/end-contract.json
  • examples/mongo-demo/migrations/app/20260415_add-posts-author-index/migration.json
  • examples/mongo-demo/migrations/app/20260415_add-posts-author-index/migration.ts
  • examples/mongo-demo/migrations/app/20260415_add-posts-author-index/start-contract.d.ts
  • examples/mongo-demo/migrations/app/20260415_add-posts-author-index/start-contract.json
  • examples/prisma-next-demo/migrations/app/20260422T0720_initial/contract.prisma
  • examples/prisma-next-demo/migrations/app/20260422T0720_initial/end-contract.d.ts
  • examples/prisma-next-demo/migrations/app/20260422T0720_initial/end-contract.json
  • examples/prisma-next-demo/migrations/app/20260422T0720_initial/migration.json
  • examples/prisma-next-demo/migrations/app/20260422T0720_initial/migration.ts
  • examples/prisma-next-demo/migrations/app/20260422T0742_migration/contract.prisma
  • examples/prisma-next-demo/migrations/app/20260422T0742_migration/end-contract.d.ts
  • examples/prisma-next-demo/migrations/app/20260422T0742_migration/end-contract.json
  • examples/prisma-next-demo/migrations/app/20260422T0742_migration/migration.json
  • examples/prisma-next-demo/migrations/app/20260422T0742_migration/migration.ts
  • examples/prisma-next-demo/migrations/app/20260422T0742_migration/start-contract.d.ts
  • examples/prisma-next-demo/migrations/app/20260422T0742_migration/start-contract.json
  • examples/prisma-next-demo/migrations/app/20260422T0748_migration/contract.prisma
  • examples/prisma-next-demo/migrations/app/20260422T0748_migration/end-contract.d.ts
  • examples/prisma-next-demo/migrations/app/20260422T0748_migration/end-contract.json
  • examples/prisma-next-demo/migrations/app/20260422T0748_migration/migration.json
  • examples/prisma-next-demo/migrations/app/20260422T0748_migration/migration.ts
  • examples/prisma-next-demo/migrations/app/20260422T0748_migration/ops.json
  • examples/prisma-next-demo/migrations/app/20260422T0748_migration/start-contract.d.ts
  • examples/prisma-next-demo/migrations/app/20260422T0748_migration/start-contract.json
  • examples/prisma-next-demo/migrations/app/20260518T1701_namespaces_bookend/contract.prisma
  • examples/prisma-next-demo/migrations/app/20260518T1701_namespaces_bookend/end-contract.d.ts
  • examples/prisma-next-demo/migrations/app/20260518T1701_namespaces_bookend/end-contract.json
  • examples/prisma-next-demo/migrations/app/20260518T1701_namespaces_bookend/migration.json
  • examples/prisma-next-demo/migrations/app/20260518T1701_namespaces_bookend/migration.ts
  • examples/prisma-next-demo/migrations/app/20260518T1701_namespaces_bookend/ops.json
  • examples/prisma-next-demo/migrations/app/20260518T1701_namespaces_bookend/start-contract.d.ts
  • examples/prisma-next-demo/migrations/app/20260518T1701_namespaces_bookend/start-contract.json
  • examples/prisma-next-demo/migrations/app/20260605T1143_public_namespaces_bookend/contract.prisma
  • examples/prisma-next-demo/migrations/app/20260605T1143_public_namespaces_bookend/end-contract.d.ts
  • examples/prisma-next-demo/migrations/app/20260605T1143_public_namespaces_bookend/end-contract.json
  • examples/prisma-next-demo/migrations/app/20260605T1143_public_namespaces_bookend/migration.json
  • examples/prisma-next-demo/migrations/app/20260605T1143_public_namespaces_bookend/migration.ts
  • examples/prisma-next-demo/migrations/app/20260605T1143_public_namespaces_bookend/ops.json
  • examples/prisma-next-demo/migrations/app/20260605T1143_public_namespaces_bookend/start-contract.d.ts
  • examples/prisma-next-demo/migrations/app/20260605T1143_public_namespaces_bookend/start-contract.json
  • examples/prisma-next-demo/migrations/app/20260605T1145_mti_variant_link_columns/contract.prisma
  • examples/prisma-next-demo/migrations/app/20260605T1145_mti_variant_link_columns/end-contract.json
  • examples/prisma-next-demo/migrations/app/20260605T1145_mti_variant_link_columns/migration.json
  • examples/prisma-next-demo/migrations/app/20260605T1145_mti_variant_link_columns/ops.json
  • examples/prisma-next-demo/migrations/app/20260605T1145_mti_variant_link_columns/start-contract.d.ts
  • examples/prisma-next-demo/migrations/app/20260605T1145_mti_variant_link_columns/start-contract.json
  • examples/prisma-next-postgis-demo/migrations/app/20260512T1309_migration/contract.prisma
  • examples/prisma-next-postgis-demo/migrations/app/20260512T1309_migration/end-contract.d.ts
  • examples/prisma-next-postgis-demo/migrations/app/20260512T1309_migration/end-contract.json
  • examples/prisma-next-postgis-demo/migrations/app/20260512T1309_migration/migration.json
  • examples/prisma-next-postgis-demo/migrations/app/20260512T1309_migration/migration.ts
  • examples/prisma-next-postgis-demo/migrations/app/20260512T1309_migration/ops.json
  • examples/retail-store/migrations/app/20260513T0505_initial/contract.prisma
  • examples/retail-store/migrations/app/20260513T0505_initial/end-contract.d.ts
  • examples/retail-store/migrations/app/20260513T0505_initial/end-contract.json
  • examples/retail-store/migrations/app/20260513T0505_initial/migration.json
  • examples/retail-store/migrations/app/20260513T0505_initial/migration.ts
  • examples/retail-store/migrations/app/20260513T0505_initial/ops.json
  • examples/retail-store/migrations/app/20260513T0507_add_product_category_index/contract.prisma
  • examples/retail-store/migrations/app/20260513T0507_add_product_category_index/end-contract.d.ts
  • examples/retail-store/migrations/app/20260513T0507_add_product_category_index/end-contract.json
  • examples/retail-store/migrations/app/20260513T0507_add_product_category_index/migration.json
  • examples/retail-store/migrations/app/20260513T0507_add_product_category_index/migration.ts
  • examples/retail-store/migrations/app/20260513T0507_add_product_category_index/ops.json
  • examples/retail-store/migrations/app/20260513T0507_add_product_category_index/start-contract.d.ts
  • examples/retail-store/migrations/app/20260513T0507_add_product_category_index/start-contract.json
  • examples/retail-store/migrations/app/20260513T0508_backfill_product_status/contract.prisma
  • examples/retail-store/migrations/app/20260513T0508_backfill_product_status/end-contract.d.ts
  • examples/retail-store/migrations/app/20260513T0508_backfill_product_status/end-contract.json
  • examples/retail-store/migrations/app/20260513T0508_backfill_product_status/migration.json
  • examples/retail-store/migrations/app/20260513T0508_backfill_product_status/migration.ts
  • examples/retail-store/migrations/app/20260513T0508_backfill_product_status/ops.json
  • examples/retail-store/migrations/app/20260513T0508_backfill_product_status/start-contract.d.ts
  • examples/retail-store/migrations/app/20260513T0508_backfill_product_status/start-contract.json
  • package.json
  • scripts/regen-example-migrations.mjs

wmadden and others added 2 commits June 8, 2026 13:20
…es:emit

Example-app migrations carry on-disk contract snapshots
(`start-contract.*` / `end-contract.*`) that went stale silently when the
contract IR shape changed: nothing regenerated them, since only extension
migrations were covered by `pnpm migrations:regen`. A stale snapshot
surfaced only when a test deserialized it and tripped the serializer
validator (TML-2808 hit this on retail-store).

Give each example-app migration a live, re-emittable source: store the
migration's end-state schema as `contract.prisma` in its directory, then
regenerate the snapshots from it with the Prisma Next CLI. This is
repeatable for any future shape change with no per-change code, because
the emitter always produces current-shape output from schema source.

- `scripts/regen-example-migrations.mjs`: walks each example-app chain and
  per migration emits `end-contract.*` from its `contract.prisma` (temp
  config that reuses the example's real `prisma-next.config.ts` and
  overrides only the schema source, so extensions / db / family stay
  correct), copies predecessor end -> successor start, rewrites the
  `migration.ts` `from:`/`to:` hash literals, re-emits `ops.json` /
  `migration.json` via `tsx`, and biome-formats. Covers retail-store,
  mongo-demo, prisma-next-demo, and prisma-next-postgis-demo.
- Wire into `fixtures:emit` via a `migrations:regen:examples` script, and
  widen the `fixtures:check` glob to `{start,end}-contract.*` so stale
  example snapshots fail the check the same way stale `contract.*`
  fixtures do.
- Regenerate all four chains' snapshots to the current contract shape.
- Make the retail-store and mongo-demo baseline migrations load their
  collection validators from `end-contract.json` instead of hardcoding
  them, so re-emitted ops match the emitter's current validators
  (including `additionalProperties: false`).
- Give prisma-next-demo's `0720_initial` foreign keys an explicit
  `schema: 'public'`; without it the FK builder emits
  `REFERENCES "undefined"` (tracked separately as a framework bug).
- `never-hand-edit-contract-fixtures`: the rule's "regenerate via
  `pnpm fixtures:emit`" promise is now true for example migrations.

Refs: TML-2838

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Signed-off-by: Will Madden <madden@prisma.io>
…te-table refactor

Main's `planner-create-table-adopts-ddl-ast` refactor removed the standalone
`createTable` migration op; the prisma-next-demo initial migration still called
it. Now that `fixtures:emit` executes each example `migration.ts` (via
`migrations:regen:examples`), that surfaced as a load-time SyntaxError in CI.

Port the five `createTable(...)` calls to the base-class `this.createTable({...})`
method with `col()` / `fn()` / `lit()` / `primaryKey()` builders, and regenerate
the migration's `ops.json` / `migration.json` (rendered DDL is unchanged). Record
an incidental-diff declaration in the 0.12→0.13 upgrade instructions so
`check-upgrade-coverage` passes.

Refs: TML-2838

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Signed-off-by: Will Madden <madden@prisma.io>
@wmadden wmadden force-pushed the tml-2838-add-example-app-migration-regen-to-pnpm-fixturesemit branch from 7056e6c to da92da8 Compare June 8, 2026 11:20
@wmadden wmadden enabled auto-merge (rebase) June 8, 2026 11:20
@wmadden-electric wmadden-electric force-pushed the tml-2838-add-example-app-migration-regen-to-pnpm-fixturesemit branch from c06b600 to f90aa48 Compare June 8, 2026 12:21
CI flakily failed with "Worker exited unexpectedly" while every test passed,
across the E2E, Integration, and packages Test jobs. The worker fork was
aborting natively inside V8:

    # Check failed: jit_page_->allocations_.erase(addr) == 1

Every affected suite stands up @prisma/dev servers backed by PGlite (Postgres
compiled to WebAssembly). Repeatedly creating and tearing down those WASM
instances trips a bug in V8 PKU-based JIT write-protection (ThreadIsolation) —
the --memory-protection-keys feature, which only engages on Linux, so it never
reproduced on macOS.

Pass --no-memory-protection-keys to the test worker forks. The flag is
rejected in NODE_OPTIONS and vitest reads it from top-level test.execArgv (not
poolOptions.forks.execArgv, which it silently drops), and a root-config
execArgv does not cascade to project workers — so it has to be set on each
config that starts PGlite. The flag lives once as pgliteWorkerExecArgv in
@prisma-next/test-utils and is wired into every PGlite-backed suite. PGlite is
unaffected.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Signed-off-by: Will Madden <madden@prisma.io>
@wmadden-electric wmadden-electric force-pushed the tml-2838-add-example-app-migration-regen-to-pnpm-fixturesemit branch from f90aa48 to 9f6c6f2 Compare June 8, 2026 12:49
@wmadden wmadden disabled auto-merge June 8, 2026 12:54
wmadden and others added 2 commits June 8, 2026 14:56
# Conflicts:
#	skills/upgrade/prisma-next-upgrade/upgrades/0.12-to-0.13/instructions.md
The PGlite WASM crash fix touches vitest configs under
packages/3-extensions/{postgres,supabase}. check-upgrade-coverage requires
the extension-author upgrade instructions to acknowledge any 3-extensions
substrate diff. This is test-harness only (no runtime/contract/public-API
change), recorded as an incidental diff.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Signed-off-by: Will Madden <madden@prisma.io>
@wmadden wmadden merged commit 940c094 into main Jun 8, 2026
21 checks passed
@wmadden wmadden deleted the tml-2838-add-example-app-migration-regen-to-pnpm-fixturesemit branch June 8, 2026 13:19
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.

2 participants