Skip to content

TML-2853: regenerate demo migration chain (follow-up — missed #817's merge race)#829

Merged
wmadden merged 2 commits into
mainfrom
tml-2853-followup-regenerate-demo-migrations
Jun 15, 2026
Merged

TML-2853: regenerate demo migration chain (follow-up — missed #817's merge race)#829
wmadden merged 2 commits into
mainfrom
tml-2853-followup-regenerate-demo-migrations

Conversation

@wmadden-electric

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

Copy link
Copy Markdown
Contributor

Linked issue

Refs TML-2853. Follow-up to #817.

Why this exists

#817 merged on a stale HEAD due to an auto-merge/merge-queue race: the migration-history regeneration commit was pushed but not yet ingested into the PR when the queue merged the prior commit. So the cutover landed, but the demo's migration chain on main still carries the pre-cutover artifact it was meant to remove — an initial migration that runs CREATE TYPE "public"."user_type" AS ENUM (…) (a state the post-cutover system can no longer produce) plus a convert_user_type_to_value_set self-edge migrating that impossible start-state to the value-set form.

As discussed on the #817 review: a migration demonstrating a transition from a now-impossible system state is an incoherent teaching artifact. This PR lands the fix that missed the merge.

What it does

Deletes the entire examples/prisma-next-demo/migrations/app/ chain (all 7 folders, including the converting self-edge) and regenerates it from scratch via the standard regen flow into a single 20260615T0000_initial that authors the current value-set / domain-enum representation directly:

  • user.kind is text NOT NULL + user_kind_check CHECK — no CREATE TYPE anywhere.
  • post.priority is text DEFAULT 'low' + post_priority_check.
  • Full current schema (pgvector, all tables/FKs/indexes) built by the one baseline migration.

migration-integrity and migration-replay tests re-pointed at the regenerated chain (replay verified against a dev DB). Spec component 4 amended to record the operator's override of the earlier "history is OUT" pin.

Chain shape (judgment call, flagging)

Collapsed to a single initial migration rather than a regenerated multi-step evolution chain — the integrity test's self-edge case injects its own synthetic migration, so it doesn't need a real multi-step chain, and a single baseline is the simplest honest shape. If a multi-migration evolution narrative (each step in the new representation) is preferred for the demo, say so and I'll regenerate as a chain.

Verification

  • pnpm build 66/66 · pnpm typecheck 138/138 · pnpm fixtures:check clean · pnpm --filter prisma-next-demo test 57/57 (integrity offline + replay against dev DB)
  • Grep-zero: no CREATE TYPE, convert_user_type, enum2, postgres-enum, pg/enum@1 in committed demo migration ops.

Checklist

  • All commits signed off (DCO).
  • Tests updated (migration-integrity + migration-replay re-pointed).
  • PR title in TML-NNNN: form.

Summary by CodeRabbit

  • Documentation

    • Updated upgrade guide to document migration chain regeneration for domain-enum representation.
  • Refactor

    • Regenerated example migration chain to use CHECK constraints for user-type validation instead of native Postgres enums.
    • Removed explicit enum value mappings across multiple migration files.
    • Consolidated and restructured migrations for improved consistency.
  • Chores

    • Updated test documentation and formatting for clarity.

@wmadden-electric wmadden-electric requested a review from a team as a code owner June 15, 2026 12:52
@coderabbitai

coderabbitai Bot commented Jun 15, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

📝 Walkthrough

Walkthrough

The prisma-next-demo example migration chain is regenerated so that user.kind is stored as a text column with a user_kind_check CHECK constraint from the initial migration, rather than a native Postgres enum type. The separate conversion migration (20260611T1856_convert_user_type_to_value_set) is deleted entirely, and user_type enum member syntax is simplified across all contract snapshots.

Changes

Migration chain regeneration for user_type value-set representation

Layer / File(s) Summary
Initial migration: enum → text + CHECK constraint
examples/prisma-next-demo/migrations/app/20260422T0720_initial/contract.prisma, migration.ts, ops.json, migration.json
user_type enum members drop explicit string assignments in contract.prisma; migration.ts imports addCheckConstraint, removes the rawSql CREATE TYPE step, and changes kind to text with a user_kind_check constraint; ops.json mirrors those structural changes; migration.json hash is updated.
user_type enum syntax update across subsequent contract snapshots
examples/prisma-next-demo/migrations/app/20260422T0742_migration/contract.prisma, 20260422T0748_migration/contract.prisma, 20260605T1145_mti_variant_link_columns/contract.prisma, 20260610T0000_add_priority_enum/contract.prisma, 20260610T2216_set_priority_default/contract.prisma
user_type enum members changed from admin = "admin" / user = "user" to bare identifiers admin / user across all five subsequent migration contract snapshots.
Deleted conversion migration
examples/prisma-next-demo/migrations/app/20260611T1856_convert_user_type_to_value_set/*
All artifacts for the now-obsolete self-edge conversion migration are removed: contract.prisma, migration.ts, migration.json, ops.json, start-contract.json, start-contract.d.ts, end-contract.json, end-contract.d.ts.
Tests and upgrade guide
examples/prisma-next-demo/test/migration-integrity.test.ts, examples/prisma-next-demo/test/migration-replay.integration.test.ts, skills/upgrade/prisma-next-upgrade/upgrades/0.13-to-0.14/instructions.md
Integrity test is reformatted (logic unchanged); replay test comments are reworded to assert kind is always text + CHECK constraint, never a native enum; upgrade guide gains a TML-2853 block describing the regenerated chain.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Possibly related PRs

  • prisma/prisma-next#797: Changes the emitter so User.kind input becomes a literal union 'admin' | 'user' with per-codec renderInputType support and updates PgEnumDescriptor, directly related to the contract type surface being regenerated in this PR.

Poem

🐇 Hop, hop, no more native enum type,
A CHECK constraint keeps the values right!
admin and user—bare names, how neat,
The conversion migration's been obsolete.
The chain is clean, the contracts align,
✨ Text columns and constraints shine!

🚥 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 title accurately describes the main change: regenerating the demo migration chain as a follow-up to a merge race in #817, which is the core objective documented in the PR summary.
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 tml-2853-followup-regenerate-demo-migrations

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

github-actions Bot commented Jun 15, 2026

Copy link
Copy Markdown

size-limit report 📦

Path Size
postgres / no-emit 152.67 KB (0%)
postgres / emit 120.9 KB (0%)
mongo / no-emit 76.92 KB (0%)
mongo / emit 71.01 KB (0%)
cf-worker / no-emit 181.08 KB (0%)
cf-worker / emit 146.05 KB (0%)

@pkg-pr-new

pkg-pr-new Bot commented Jun 15, 2026

Copy link
Copy Markdown

Open in StackBlitz

@prisma-next/extension-author-tools

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

@prisma-next/mongo-runtime

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

@prisma-next/family-mongo

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

@prisma-next/sql-runtime

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

@prisma-next/family-sql

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

@prisma-next/extension-arktype-json

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

@prisma-next/middleware-cache

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

@prisma-next/mongo

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

@prisma-next/extension-paradedb

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

@prisma-next/extension-pgvector

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

@prisma-next/extension-postgis

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

@prisma-next/postgres

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

@prisma-next/sql-orm-client

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

@prisma-next/sqlite

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

@prisma-next/extension-supabase

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

@prisma-next/target-mongo

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

@prisma-next/adapter-mongo

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

@prisma-next/driver-mongo

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

@prisma-next/contract

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

@prisma-next/utils

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

@prisma-next/config

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

@prisma-next/errors

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

@prisma-next/framework-components

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

@prisma-next/operations

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

@prisma-next/ts-render

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

@prisma-next/contract-authoring

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

@prisma-next/ids

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

@prisma-next/psl-parser

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

@prisma-next/psl-printer

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

@prisma-next/cli

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

@prisma-next/cli-telemetry

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

@prisma-next/emitter

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

@prisma-next/migration-tools

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

prisma-next

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

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

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

@prisma-next/mongo-codec

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

@prisma-next/mongo-contract

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

@prisma-next/mongo-value

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

@prisma-next/mongo-contract-psl

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

@prisma-next/mongo-contract-ts

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

@prisma-next/mongo-emitter

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

@prisma-next/mongo-schema-ir

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

@prisma-next/mongo-query-ast

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

@prisma-next/mongo-orm

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

@prisma-next/mongo-query-builder

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

@prisma-next/mongo-lowering

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

@prisma-next/mongo-wire

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

@prisma-next/sql-contract

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

@prisma-next/sql-errors

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

@prisma-next/sql-operations

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

@prisma-next/sql-schema-ir

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

@prisma-next/sql-contract-psl

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

@prisma-next/sql-contract-ts

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

@prisma-next/sql-contract-emitter

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

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

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

@prisma-next/sql-relational-core

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

@prisma-next/sql-builder

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

@prisma-next/target-postgres

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

@prisma-next/target-sqlite

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

@prisma-next/adapter-postgres

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

@prisma-next/adapter-sqlite

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

@prisma-next/driver-postgres

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

@prisma-next/driver-sqlite

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

commit: 2970087

wmadden-electric and others added 2 commits June 15, 2026 15:17
Replaces the single from-empty baseline (the prior attempt on this branch) with a
multi-step incremental chain re-authored from the original 7-folder history, so the
demo still exercises the migration CLI's apply-successive-migrations path
(db update, migration status/list across a chain).

What changed vs the original chain:
- Initial migration (20260422T0720_initial): the hand-written `CREATE TYPE
  user_type AS ENUM` rawSql op is removed; `user.kind` is now a `text` column and a
  `user_kind_check` CHECK constraint enforces the value set from the start.
- Deleted 20260611T1856_convert_user_type_to_value_set: nothing to convert now —
  user_type was never native.
- Kept every other incremental milestone unchanged: displayName add (0742),
  displayName backfill + NOT NULL (0748), MTI variant link columns (mti_variant),
  post.priority value-set + check (add_priority_enum), priority default
  (set_priority_default).
- All user_type enum blocks in the per-step contract.prisma snapshots use the
  bare-member form, matching the current src/prisma/contract.prisma.
- Derived artifacts regenerated via scripts/regen-example-migrations.mjs. The chain
  is hash-continuous and its final to-hash equals the current contract storageHash;
  it applies cleanly empty→current.

Tests re-pointed:
- migration-replay.integration.test.ts: doc comment updated to describe the new
  chain (assertions already verify text + user_kind_check, no native enum).
- migration-integrity.test.ts: added an explicit databaseOperation timeout to the
  positive aggregate-check test (cold import of the large contract.json exceeds the
  100ms global default).

Upgrade coverage: recorded an incidental-regeneration declaration in
skills/upgrade/prisma-next-upgrade/upgrades/0.13-to-0.14/instructions.md (examples-only
diff, no new consumer action beyond the existing enum-becomes-domain-concept entry).

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Signed-off-by: willbot <w.a.madden+machine@gmail.com>
Signed-off-by: Will Madden <madden@prisma.io>
…rride, #829)

Revises spec component 4 to record the multi-step regeneration approach. The earlier
single-migration framing (#817 review) was itself overruled on #829: the demo must
keep a multi-step incremental chain to demonstrate the incremental migration CLI.
Component 4 now describes re-authoring the original history in the value-set
representation — initial migration creates user.kind as text + user_kind_check from
the start, convert self-edge removed, all other incremental milestones preserved.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Signed-off-by: willbot <w.a.madden+machine@gmail.com>
Signed-off-by: Will Madden <madden@prisma.io>
@wmadden-electric wmadden-electric force-pushed the tml-2853-followup-regenerate-demo-migrations branch from 4ba2d10 to 2970087 Compare June 15, 2026 14:00

@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

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
skills/upgrade/prisma-next-upgrade/upgrades/0.13-to-0.14/instructions.md (1)

298-298: ⚠️ Potential issue | 🟡 Minor | ⚡ Quick win

Remove or update the example migration reference that is being deleted in this PR.

The upgrade guide at line 298 references examples/prisma-next-demo/migrations/app/20260611T1856_convert_user_type_to_value_set/migration.ts as a worked example for users converting their own databases. However, the PR's TML-2853 block (lines 359–373) states that this migration (the "self-edge conversion migration") is being removed from the regenerated chain. The documentation will reference a path that no longer exists in the repository after this PR merges, violating the doc-maintenance guideline to keep links and references current.

Fix: Either (1) remove the specific path reference at line 298 and replace it with a generic description of the conversion pattern (without relying on the demo example), or (2) retain the conversion migration in the demo for documentation purposes.

🤖 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 `@skills/upgrade/prisma-next-upgrade/upgrades/0.13-to-0.14/instructions.md` at
line 298, The upgrade guide at line 298 contains a specific reference to the
example migration at
`examples/prisma-next-demo/migrations/app/20260611T1856_convert_user_type_to_value_set/migration.ts`,
but the TML-2853 block (lines 359–373) indicates this migration is being removed
from the regenerated chain. Remove the specific file path reference and replace
it with a generic description of the three-operation conversion pattern
(data-class ALTER with USING, addCheckConstraint, and DROP TYPE) with
pre/postchecks for idempotency, OR alternatively ensure the conversion migration
is retained in the demo repo so the documented reference remains valid.

Source: Coding guidelines

🤖 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 `@skills/upgrade/prisma-next-upgrade/upgrades/0.13-to-0.14/instructions.md`:
- Around line 359-373: The example reference at line 298 in the
`enum-becomes-domain-concept` section points to the
`20260611T1856_convert_user_type_to_value_set` migration, which is being removed
during the migration chain regeneration described in the PR comment. Locate this
stale migration reference in the documentation and either remove it entirely or
replace it with a reference to a migration that will still exist after the chain
is regenerated (such as one of the preserved incremental milestones like
displayName, MTI variant link columns, or post.priority value-set migration).

---

Outside diff comments:
In `@skills/upgrade/prisma-next-upgrade/upgrades/0.13-to-0.14/instructions.md`:
- Line 298: The upgrade guide at line 298 contains a specific reference to the
example migration at
`examples/prisma-next-demo/migrations/app/20260611T1856_convert_user_type_to_value_set/migration.ts`,
but the TML-2853 block (lines 359–373) indicates this migration is being removed
from the regenerated chain. Remove the specific file path reference and replace
it with a generic description of the three-operation conversion pattern
(data-class ALTER with USING, addCheckConstraint, and DROP TYPE) with
pre/postchecks for idempotency, OR alternatively ensure the conversion migration
is retained in the demo repo so the documented reference remains valid.
🪄 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: c457f0d9-d345-446a-b68b-485adedaa6ca

📥 Commits

Reviewing files that changed from the base of the PR and between df80257 and 2970087.

⛔ Files ignored due to path filters (1)
  • projects/enums-as-domain-concept/slices/cutover-delete-native-enums/spec.md is excluded by !projects/**
📒 Files selected for processing (20)
  • examples/prisma-next-demo/migrations/app/20260422T0720_initial/contract.prisma
  • 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/20260422T0720_initial/ops.json
  • examples/prisma-next-demo/migrations/app/20260422T0742_migration/contract.prisma
  • examples/prisma-next-demo/migrations/app/20260422T0748_migration/contract.prisma
  • examples/prisma-next-demo/migrations/app/20260605T1145_mti_variant_link_columns/contract.prisma
  • examples/prisma-next-demo/migrations/app/20260610T0000_add_priority_enum/contract.prisma
  • examples/prisma-next-demo/migrations/app/20260610T2216_set_priority_default/contract.prisma
  • examples/prisma-next-demo/migrations/app/20260611T1856_convert_user_type_to_value_set/contract.prisma
  • examples/prisma-next-demo/migrations/app/20260611T1856_convert_user_type_to_value_set/end-contract.d.ts
  • examples/prisma-next-demo/migrations/app/20260611T1856_convert_user_type_to_value_set/end-contract.json
  • examples/prisma-next-demo/migrations/app/20260611T1856_convert_user_type_to_value_set/migration.json
  • examples/prisma-next-demo/migrations/app/20260611T1856_convert_user_type_to_value_set/migration.ts
  • examples/prisma-next-demo/migrations/app/20260611T1856_convert_user_type_to_value_set/ops.json
  • examples/prisma-next-demo/migrations/app/20260611T1856_convert_user_type_to_value_set/start-contract.d.ts
  • examples/prisma-next-demo/migrations/app/20260611T1856_convert_user_type_to_value_set/start-contract.json
  • examples/prisma-next-demo/test/migration-integrity.test.ts
  • examples/prisma-next-demo/test/migration-replay.integration.test.ts
  • skills/upgrade/prisma-next-upgrade/upgrades/0.13-to-0.14/instructions.md
💤 Files with no reviewable changes (8)
  • examples/prisma-next-demo/migrations/app/20260611T1856_convert_user_type_to_value_set/ops.json
  • examples/prisma-next-demo/migrations/app/20260611T1856_convert_user_type_to_value_set/migration.ts
  • examples/prisma-next-demo/migrations/app/20260611T1856_convert_user_type_to_value_set/start-contract.json
  • examples/prisma-next-demo/migrations/app/20260611T1856_convert_user_type_to_value_set/end-contract.d.ts
  • examples/prisma-next-demo/migrations/app/20260611T1856_convert_user_type_to_value_set/migration.json
  • examples/prisma-next-demo/migrations/app/20260611T1856_convert_user_type_to_value_set/end-contract.json
  • examples/prisma-next-demo/migrations/app/20260611T1856_convert_user_type_to_value_set/start-contract.d.ts
  • examples/prisma-next-demo/migrations/app/20260611T1856_convert_user_type_to_value_set/contract.prisma

@wmadden wmadden enabled auto-merge June 15, 2026 14:10
@wmadden wmadden added this pull request to the merge queue Jun 15, 2026
Merged via the queue into main with commit 29a1bfb Jun 15, 2026
21 checks passed
@wmadden wmadden deleted the tml-2853-followup-regenerate-demo-migrations branch June 15, 2026 14:26
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