Skip to content

feat(examples): regenerate the diamond migration fixture as a complete, renderable set#677

Open
wmadden-electric wants to merge 3 commits into
mainfrom
regenerate-diamond-migration-fixture
Open

feat(examples): regenerate the diamond migration fixture as a complete, renderable set#677
wmadden-electric wants to merge 3 commits into
mainfrom
regenerate-diamond-migration-fixture

Conversation

@wmadden-electric
Copy link
Copy Markdown
Contributor

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

Summary

The examples/prisma-next-demo/migration-fixtures/diamond fixture was topology-only — each node had just migration.json + ops.json with synthetic hashes and no contract snapshots — so the live read/graph path (readGraphNodeEndContract) couldn't load it (missing destination contract snapshot). Because the hashes were synthetic with no backing contract content, the only correct fix was to regenerate the whole fixture so every artifact agrees.

This regenerates diamond offline (via prisma-next migration plan, no DB) into a complete, internally-consistent diamond and adds a dedicated demo config so it renders via --config without touching the main demo config.

  • 5 nodes, full artifact set (migration.json, ops.json, end-contract.json, end-contract.d.ts, migration.ts; branched/merge nodes also carry start-contract.*, matching the showcase fixture).
  • Diamond topology that converges:
    • ∅ → C1 (init)
    • C1 → C2 (alice_add_phone, +phone) / C1 → C3 (bob_add_avatar, +avatar)
    • C2 → C5 (merge_alice) / C3 → C5 (merge_bob) — both land on C5
    • refs/prod.json → C5
  • App-space only — dropped the old vector extension, so there are no extension-space packages.
  • New prisma-next.diamond.config.ts (mirrors prisma-next.showcase.config.ts); the main prisma-next.config.ts is untouched.

Rendered graph (migration graph --config ./prisma-next.diamond.config.ts)

│ ○ ∅
│ │ 20260301T1000_init
│ ▾
│ ┌─────────○ 789dd79─┐
│ 20260302T1100_bob_add_avatar │ │ 20260302T1000_alice_add_phone
│ ▾                            ▾
│ ○ 7e3fa7f                    ○ 93be6c2
│ 20260303T1100_merge_bob │ │ 20260303T1000_merge_alice
│ └─────────▾─────────┘
│ ○ f9a41d7 prod ◆ contract
│ 5 node(s), 5 edge(s)

Test plan

  • prisma-next migration check --config ./prisma-next.diamond.config.ts{ ok: true, "All checks passed" }
  • prisma-next migration graph --config ./prisma-next.diamond.config.ts (default + --tree) renders a clean 5-node/5-edge diamond, no errors
  • Every end-contract storageHash matches its migration.json to; merge_alice.to == merge_bob.to == refs/prod.json.hash
  • Reviewer (opus) verdict: SATISFIED, 7/7 ACs
  • Scope confined to diamond-contract/**, prisma-next.diamond.config.ts, migration-fixtures/diamond/**

Independent of the lane-colors PR (#674); branched off main.

Summary by CodeRabbit

  • New Features

    • Added example project demonstrating Prisma-Next integration with PostgreSQL, including schema migrations and type-safe database contracts for a user model.
  • Chores

    • Added configuration and fixture files for the new example project.

wmadden added 3 commits June 1, 2026 19:04
The on-disk diamond fixture is topology-only with synthetic hashes, so it
can't be loaded by the live read/graph path. Spec a full offline regeneration
via `migration plan` plus a dedicated demo config.
Replace topology-only synthetic hashes with full migration packages
planned from diamond-contract sources so migration graph and check
work via prisma-next.diamond.config.ts.

Signed-off-by: Will Madden <madden@prisma.io>
@wmadden-electric wmadden-electric requested a review from a team as a code owner June 1, 2026 17:15
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Jun 1, 2026

Review Change Stack

📝 Walkthrough

Walkthrough

This PR adds a comprehensive Prisma-Next demo fixture set illustrating contract evolution and parallel schema migrations. It includes five contract variants (c1–c5) with progressive field additions, initial table creation, two parallel migration branches adding phone and avatar columns, and merge operations combining those changes.

Changes

Diamond Demo Fixtures and Configuration

Layer / File(s) Summary
Contract c1: Basic user schema
examples/prisma-next-demo/diamond-contract/c1.prisma, c1.d.ts, c1.json
Initial contract defines a minimal user model with id and email fields, including generated TypeScript type definitions binding Postgres codec/query operation types and JSON contract metadata.
Contract c2: user with phone field
examples/prisma-next-demo/diamond-contract/c2.prisma, c2.d.ts, c2.json
Extends c1 by adding an optional phone field, with corresponding Prisma schema updates and regenerated contract type definitions.
Contract c3: user with avatar field
examples/prisma-next-demo/diamond-contract/c3.prisma, c3.d.ts, c3.json
Adds an optional avatar field to the schema, providing Prisma schema and generated contract type definitions for the user model with three optional fields.
Contract c5: Complete user schema
examples/prisma-next-demo/diamond-contract/c5.prisma, c5.d.ts, c5.json
Provides the full contract including all fields (id, email, phone, avatar) with complete type definitions and JSON contract specification for the final schema state.
Initial migration: create table
examples/prisma-next-demo/migration-fixtures/diamond/app/20260301T1000_init/migration.ts, migration.json, ops.json, end-contract.d.ts, end-contract.json
Defines the first migration creating the user table with id and email columns, including migration class descriptor, operation definitions, and generated end-state contract artifacts.
Alice migration: add phone column
examples/prisma-next-demo/migration-fixtures/diamond/app/20260302T1000_alice_add_phone/migration.ts, migration.json, ops.json, start-contract.d.ts, start-contract.json, end-contract.d.ts, end-contract.json
Parallel migration branch adding a nullable phone column to user, with start/end contract states and operation metadata showing schema evolution.
Bob migration: add avatar column
examples/prisma-next-demo/migration-fixtures/diamond/app/20260302T1100_bob_add_avatar/migration.ts, migration.json, ops.json, start-contract.d.ts, start-contract.json, end-contract.d.ts, end-contract.json
Parallel migration branch adding a nullable avatar column to user, with corresponding contract definitions and operation details.
Merge alice: combine phone addition
examples/prisma-next-demo/migration-fixtures/diamond/app/20260303T1000_merge_alice/migration.ts, migration.json, ops.json, start-contract.d.ts, start-contract.json, end-contract.d.ts, end-contract.json
Merge migration combining alice's phone addition, with start/end contracts showing the merged schema state.
Merge bob: combine avatar addition
examples/prisma-next-demo/migration-fixtures/diamond/app/20260303T1100_merge_bob/migration.ts, migration.json, ops.json, start-contract.d.ts, start-contract.json, end-contract.d.ts, end-contract.json
Merge migration combining bob's avatar addition, with start/end contracts reflecting the final schema state including both phone and avatar fields.
Configuration and reference updates
examples/prisma-next-demo/prisma-next.diamond.config.ts, examples/prisma-next-demo/migration-fixtures/diamond/app/refs/prod.json
Adds the Prisma-Next configuration file pointing to c5 as the contract schema and updates the production reference hash.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~12 minutes

Possibly related PRs

  • prisma/prisma-next#534: The main PR regenerates prisma-next demo contract and migration fixtures to use the new per-namespace storage.namespaces.__unbound__ / target-qualified storage+FK shape introduced by the retrieved PR (changing emitted ContractBase typings and the generated contract*.json/*.d.ts/ops.json accordingly).

Suggested reviewers

  • aqrln

Poem

🐰 Through diamonds bright, a schema grows,
From Alice's branch, the phone field flows,
And Bob adds avatar, side by side,
Then merged together, unified,
A fixture dance, contracts align—
Demo perfection, by design!

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The PR title accurately describes the main change: regenerating the diamond migration fixture as a complete, renderable set with full contract artifacts.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch regenerate-diamond-migration-fixture

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@github-actions
Copy link
Copy Markdown

github-actions Bot commented Jun 1, 2026

size-limit report 📦

Path Size
postgres / no-emit 135.93 KB (0%)
postgres / emit 125.59 KB (0%)
mongo / no-emit 75.69 KB (0%)
mongo / emit 70.68 KB (0%)

@pkg-pr-new
Copy link
Copy Markdown

pkg-pr-new Bot commented Jun 1, 2026

Open in StackBlitz

@prisma-next/extension-author-tools

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

@prisma-next/mongo-runtime

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

@prisma-next/family-mongo

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

@prisma-next/sql-runtime

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

@prisma-next/family-sql

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

@prisma-next/extension-arktype-json

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

@prisma-next/middleware-cache

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

@prisma-next/mongo

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

@prisma-next/extension-paradedb

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

@prisma-next/extension-pgvector

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

@prisma-next/extension-postgis

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

@prisma-next/postgres

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

@prisma-next/sql-orm-client

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

@prisma-next/sqlite

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

@prisma-next/target-mongo

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

@prisma-next/adapter-mongo

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

@prisma-next/driver-mongo

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

@prisma-next/contract

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

@prisma-next/utils

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

@prisma-next/config

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

@prisma-next/errors

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

@prisma-next/framework-components

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

@prisma-next/operations

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

@prisma-next/ts-render

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

@prisma-next/contract-authoring

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

@prisma-next/ids

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

@prisma-next/psl-parser

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

@prisma-next/psl-printer

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

@prisma-next/cli

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

@prisma-next/cli-telemetry

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

@prisma-next/emitter

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

@prisma-next/migration-tools

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

prisma-next

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

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

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

@prisma-next/mongo-codec

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

@prisma-next/mongo-contract

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

@prisma-next/mongo-value

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

@prisma-next/mongo-contract-psl

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

@prisma-next/mongo-contract-ts

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

@prisma-next/mongo-emitter

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

@prisma-next/mongo-schema-ir

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

@prisma-next/mongo-query-ast

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

@prisma-next/mongo-orm

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

@prisma-next/mongo-query-builder

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

@prisma-next/mongo-lowering

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

@prisma-next/mongo-wire

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

@prisma-next/sql-contract

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

@prisma-next/sql-errors

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

@prisma-next/sql-operations

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

@prisma-next/sql-schema-ir

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

@prisma-next/sql-contract-psl

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

@prisma-next/sql-contract-ts

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

@prisma-next/sql-contract-emitter

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

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

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

@prisma-next/sql-relational-core

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

@prisma-next/sql-builder

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

@prisma-next/target-postgres

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

@prisma-next/target-sqlite

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

@prisma-next/adapter-postgres

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

@prisma-next/adapter-sqlite

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

@prisma-next/driver-postgres

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

@prisma-next/driver-sqlite

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

commit: b44b4a3

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 3

🤖 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/prisma-next-demo/migration-fixtures/diamond/app/20260303T1100_merge_bob/migration.ts`:
- Around line 14-19: The migration in merge_bob incorrectly adds a "phone"
column; update the addColumn call in migration.ts (the addColumn('__unbound__',
'user', {...}) invocation inside the merge_bob migration) to add Bob's "avatar"
column instead of "phone" — i.e., change the name field to 'avatar' and keep the
same typeSql/defaultSql/nullable settings (or adjust if avatar has different
constraints) so the merge_bob migration applies Bob's avatar onto Alice's branch
that already has phone.

In
`@examples/prisma-next-demo/migration-fixtures/diamond/app/20260303T1100_merge_bob/ops.json`:
- Around line 3-12: In the merge_bob migration ops.json entry, replace the
incorrect "phone" references with "avatar": update the operation "id" from
"column.user.phone" to "column.user.avatar", change the "label" from 'Add column
"phone" to "user"' to 'Add column "avatar" to "user"', and set
target.details.name to "avatar"; then update any corresponding SQL statements
(the CREATE/ALTER column references named "phone") in the migration
SQL/migration.ts that applied this op so they create/alter "avatar" instead of
"phone" (ensure the migration file for 20260303T1100_merge_bob and any function
handling this op use "column.user.avatar").

In
`@examples/prisma-next-demo/migration-fixtures/diamond/app/20260303T1100_merge_bob/start-contract.d.ts`:
- Around line 47-60: The start contract's types (FieldOutputTypes and
FieldInputTypes) currently include `avatar` and lack `phone`, which is inverted
for merge_bob; update both FieldOutputTypes.user and FieldInputTypes.user to
replace the `avatar` field with `phone` using the appropriate CodecTypes entries
(for output use CodecTypes['pg/text@1']['output'] | null and for input use
CodecTypes['pg/text@1']['input'] | null) so the contract starts from Alice's
branch (with phone) and then merge_bob can add avatar.
🪄 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: 9c69f723-33df-4c8e-9080-b5caa7298098

📥 Commits

Reviewing files that changed from the base of the PR and between 7ff5200 and b44b4a3.

⛔ Files ignored due to path filters (2)
  • projects/migration-graph-rendering/slices/diamond-fixture-regeneration/code-review.md is excluded by !projects/**
  • projects/migration-graph-rendering/slices/diamond-fixture-regeneration/spec.md is excluded by !projects/**
📒 Files selected for processing (47)
  • examples/prisma-next-demo/diamond-contract/c1.d.ts
  • examples/prisma-next-demo/diamond-contract/c1.json
  • examples/prisma-next-demo/diamond-contract/c1.prisma
  • examples/prisma-next-demo/diamond-contract/c2.d.ts
  • examples/prisma-next-demo/diamond-contract/c2.json
  • examples/prisma-next-demo/diamond-contract/c2.prisma
  • examples/prisma-next-demo/diamond-contract/c3.d.ts
  • examples/prisma-next-demo/diamond-contract/c3.json
  • examples/prisma-next-demo/diamond-contract/c3.prisma
  • examples/prisma-next-demo/diamond-contract/c5.d.ts
  • examples/prisma-next-demo/diamond-contract/c5.json
  • examples/prisma-next-demo/diamond-contract/c5.prisma
  • examples/prisma-next-demo/migration-fixtures/diamond/app/20260301T1000_init/end-contract.d.ts
  • examples/prisma-next-demo/migration-fixtures/diamond/app/20260301T1000_init/end-contract.json
  • examples/prisma-next-demo/migration-fixtures/diamond/app/20260301T1000_init/migration.json
  • examples/prisma-next-demo/migration-fixtures/diamond/app/20260301T1000_init/migration.ts
  • examples/prisma-next-demo/migration-fixtures/diamond/app/20260301T1000_init/ops.json
  • examples/prisma-next-demo/migration-fixtures/diamond/app/20260302T1000_alice_add_phone/end-contract.d.ts
  • examples/prisma-next-demo/migration-fixtures/diamond/app/20260302T1000_alice_add_phone/end-contract.json
  • examples/prisma-next-demo/migration-fixtures/diamond/app/20260302T1000_alice_add_phone/migration.json
  • examples/prisma-next-demo/migration-fixtures/diamond/app/20260302T1000_alice_add_phone/migration.ts
  • examples/prisma-next-demo/migration-fixtures/diamond/app/20260302T1000_alice_add_phone/ops.json
  • examples/prisma-next-demo/migration-fixtures/diamond/app/20260302T1000_alice_add_phone/start-contract.d.ts
  • examples/prisma-next-demo/migration-fixtures/diamond/app/20260302T1000_alice_add_phone/start-contract.json
  • examples/prisma-next-demo/migration-fixtures/diamond/app/20260302T1100_bob_add_avatar/end-contract.d.ts
  • examples/prisma-next-demo/migration-fixtures/diamond/app/20260302T1100_bob_add_avatar/end-contract.json
  • examples/prisma-next-demo/migration-fixtures/diamond/app/20260302T1100_bob_add_avatar/migration.json
  • examples/prisma-next-demo/migration-fixtures/diamond/app/20260302T1100_bob_add_avatar/migration.ts
  • examples/prisma-next-demo/migration-fixtures/diamond/app/20260302T1100_bob_add_avatar/ops.json
  • examples/prisma-next-demo/migration-fixtures/diamond/app/20260302T1100_bob_add_avatar/start-contract.d.ts
  • examples/prisma-next-demo/migration-fixtures/diamond/app/20260302T1100_bob_add_avatar/start-contract.json
  • examples/prisma-next-demo/migration-fixtures/diamond/app/20260303T1000_merge_alice/end-contract.d.ts
  • examples/prisma-next-demo/migration-fixtures/diamond/app/20260303T1000_merge_alice/end-contract.json
  • examples/prisma-next-demo/migration-fixtures/diamond/app/20260303T1000_merge_alice/migration.json
  • examples/prisma-next-demo/migration-fixtures/diamond/app/20260303T1000_merge_alice/migration.ts
  • examples/prisma-next-demo/migration-fixtures/diamond/app/20260303T1000_merge_alice/ops.json
  • examples/prisma-next-demo/migration-fixtures/diamond/app/20260303T1000_merge_alice/start-contract.d.ts
  • examples/prisma-next-demo/migration-fixtures/diamond/app/20260303T1000_merge_alice/start-contract.json
  • examples/prisma-next-demo/migration-fixtures/diamond/app/20260303T1100_merge_bob/end-contract.d.ts
  • examples/prisma-next-demo/migration-fixtures/diamond/app/20260303T1100_merge_bob/end-contract.json
  • examples/prisma-next-demo/migration-fixtures/diamond/app/20260303T1100_merge_bob/migration.json
  • examples/prisma-next-demo/migration-fixtures/diamond/app/20260303T1100_merge_bob/migration.ts
  • examples/prisma-next-demo/migration-fixtures/diamond/app/20260303T1100_merge_bob/ops.json
  • examples/prisma-next-demo/migration-fixtures/diamond/app/20260303T1100_merge_bob/start-contract.d.ts
  • examples/prisma-next-demo/migration-fixtures/diamond/app/20260303T1100_merge_bob/start-contract.json
  • examples/prisma-next-demo/migration-fixtures/diamond/app/refs/prod.json
  • examples/prisma-next-demo/prisma-next.diamond.config.ts

Comment on lines +14 to +19
addColumn('__unbound__', 'user', {
name: 'phone',
typeSql: 'text',
defaultSql: '',
nullable: true,
}),
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.

⚠️ Potential issue | 🔴 Critical | ⚡ Quick win

Critical: Wrong column name in merge_bob migration.

This migration adds a phone column, but merge_bob should add the avatar column (Bob's change) onto Alice's branch (which already has phone). The diamond topology requires:

  • Alice's branch (C2): has phone
  • Bob's branch (C3): has avatar
  • merge_bob: takes Alice's branch (with phone) + adds Bob's avatar
  • merge_alice: takes Bob's branch (with avatar) + adds Alice's phone
🐛 Proposed fix
     addColumn('__unbound__', 'user', {
-      name: 'phone',
+      name: 'avatar',
       typeSql: 'text',
       defaultSql: '',
       nullable: true,
     }),
🤖 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/migration-fixtures/diamond/app/20260303T1100_merge_bob/migration.ts`
around lines 14 - 19, The migration in merge_bob incorrectly adds a "phone"
column; update the addColumn call in migration.ts (the addColumn('__unbound__',
'user', {...}) invocation inside the merge_bob migration) to add Bob's "avatar"
column instead of "phone" — i.e., change the name field to 'avatar' and keep the
same typeSql/defaultSql/nullable settings (or adjust if avatar has different
constraints) so the merge_bob migration applies Bob's avatar onto Alice's branch
that already has phone.

Comment on lines 3 to +12
"id": "column.user.phone",
"label": "Add column phone to user",
"summary": "Adds column phone to table user",
"label": "Add column \"phone\" to \"user\"",
"operationClass": "additive",
"target": {
"id": "postgres",
"details": {
"schema": "public",
"objectType": "table",
"name": "user"
"schema": "__unbound__",
"objectType": "column",
"name": "phone",
"table": "user"
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.

⚠️ Potential issue | 🔴 Critical | ⚡ Quick win

Critical: Wrong column name in ops.json.

Consistent with the issue in migration.ts, this operation adds phone but should add avatar. The operation ID, label, and column name must all reference avatar for the merge_bob migration.

🐛 Proposed fix
   {
-    "id": "column.user.phone",
-    "label": "Add column \"phone\" to \"user\"",
+    "id": "column.user.avatar",
+    "label": "Add column \"avatar\" to \"user\"",
     "operationClass": "additive",
     "target": {
       "id": "postgres",
       "details": {
         "schema": "__unbound__",
         "objectType": "column",
-        "name": "phone",
+        "name": "avatar",
         "table": "user"
       }
     },

And update the SQL statements:

     "precheck": [
       {
-        "description": "ensure column \"phone\" is missing",
-        "sql": "SELECT NOT EXISTS (\n  SELECT 1\n  FROM information_schema.columns\n  WHERE table_schema = current_schema()\n    AND table_name = 'user'\n    AND column_name = 'phone'\n)"
+        "description": "ensure column \"avatar\" is missing",
+        "sql": "SELECT NOT EXISTS (\n  SELECT 1\n  FROM information_schema.columns\n  WHERE table_schema = current_schema()\n    AND table_name = 'user'\n    AND column_name = 'avatar'\n)"
       }
     ],
     "execute": [
       {
-        "description": "add column \"phone\"",
-        "sql": "ALTER TABLE \"user\" ADD COLUMN \"phone\" text"
+        "description": "add column \"avatar\"",
+        "sql": "ALTER TABLE \"user\" ADD COLUMN \"avatar\" text"
       }
     ],
     "postcheck": [
       {
-        "description": "verify column \"phone\" exists",
-        "sql": "SELECT EXISTS (\n  SELECT 1\n  FROM information_schema.columns\n  WHERE table_schema = current_schema()\n    AND table_name = 'user'\n    AND column_name = 'phone'\n)"
+        "description": "verify column \"avatar\" exists",
+        "sql": "SELECT EXISTS (\n  SELECT 1\n  FROM information_schema.columns\n  WHERE table_schema = current_schema()\n    AND table_name = 'user'\n    AND column_name = 'avatar'\n)"
       }
     ]
🤖 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/migration-fixtures/diamond/app/20260303T1100_merge_bob/ops.json`
around lines 3 - 12, In the merge_bob migration ops.json entry, replace the
incorrect "phone" references with "avatar": update the operation "id" from
"column.user.phone" to "column.user.avatar", change the "label" from 'Add column
"phone" to "user"' to 'Add column "avatar" to "user"', and set
target.details.name to "avatar"; then update any corresponding SQL statements
(the CREATE/ALTER column references named "phone") in the migration
SQL/migration.ts that applied this op so they create/alter "avatar" instead of
"phone" (ensure the migration file for 20260303T1100_merge_bob and any function
handling this op use "column.user.avatar").

Comment on lines +47 to +60
export type FieldOutputTypes = {
readonly user: {
readonly id: Char<36>;
readonly email: CodecTypes['pg/text@1']['output'];
readonly avatar: CodecTypes['pg/text@1']['output'] | null;
};
};
export type FieldInputTypes = {
readonly user: {
readonly id: CodecTypes['sql/char@1']['input'];
readonly email: CodecTypes['pg/text@1']['input'];
readonly avatar: CodecTypes['pg/text@1']['input'] | null;
};
};
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.

⚠️ Potential issue | 🔴 Critical | ⚡ Quick win

Critical: start-contract has wrong fields for merge_bob.

The start contract includes avatar but no phone, indicating this starts from Bob's branch (C3). However, merge_bob should start from Alice's branch (C2, which has phone) and add Bob's avatar.

This confirms the entire migration is inverted:

  • Current: starts with avatar, adds phone → this is merge_alice behavior
  • Expected: starts with phone, adds avatar → correct merge_bob behavior

This start-contract should have phone instead of avatar, matching Alice's branch as the starting point.

🤖 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/migration-fixtures/diamond/app/20260303T1100_merge_bob/start-contract.d.ts`
around lines 47 - 60, The start contract's types (FieldOutputTypes and
FieldInputTypes) currently include `avatar` and lack `phone`, which is inverted
for merge_bob; update both FieldOutputTypes.user and FieldInputTypes.user to
replace the `avatar` field with `phone` using the appropriate CodecTypes entries
(for output use CodecTypes['pg/text@1']['output'] | null and for input use
CodecTypes['pg/text@1']['input'] | null) so the contract starts from Alice's
branch (with phone) and then merge_bob can add avatar.

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