GeezerVison is showing github.com — TML-3704: MySQL can migrate, verify and sign, and each runner says what a failed migration left behind by wmadden-electric · Pull Request #30841 · prisma/orm
Conversation
wmadden-electric
commented
Oct 22, 2026
•
edited by coderabbitai
Bot
Loading
Uh oh!
There was an error while loading. Please reload this page.
With this PR, the MySQL target from #30836 can migrate, verify and sign a database. Against an empty MySQL 8.4 database and the example contract (a User with a unique email and an enum role, and a Post that belongs to a User):
$ prisma migration plan --name init
$ prisma db migrate
$ prisma db verify
✔ Database matches the contract
$ prisma db sign
migration plan writes CREATE TABLE for both tables, the unique index on email, the enum('USER','ADMIN') column and the foreign key. Adding a nullable field and planning again writes ALTER TABLE … ADD COLUMN. Removing it asks the usual data-loss question, and with --delete it writes DROP COLUMN.
This is slice 2b of the MySQL proof of concept (projects/mysql-poc/). The project builds a narrow MySQL target to find shared code that assumes Postgres or SQLite while APIs can still change. This slice found the biggest such assumption so far, in how migrations promise to fail.
The decision: each runner says what a failed migration left behind
The SQL family promised that if a migration fails, every contract space's changes are rolled back. That's true on Postgres and SQLite, where DDL runs inside a transaction. MySQL commits on every DDL statement, so it can't keep that promise. Mongo never could, for the same reason.
So the promise moves from the family to each target's runner, and is stated per run. A failed apply reports:
databaseUnchanged: whether the database is as it was before the run;
failingSpace: which contract space failed;
- a message saying what stayed.
On Postgres and SQLite the runner rolls back and reports databaseUnchanged: true, exactly as before. On MySQL and Mongo, the operations that already ran stay applied, the runner says so, and running db migrate again skips what was applied and finishes the rest. The CLI shows the runner's failure as it is, and names the failing space when it isn't the default app space. Every doc that promised a family-wide rollback now says this: the runner types, the CLI docs, ADR 212 (with a dated note on what changed), and the Migration System and MongoDB Family docs.
How the MySQL runner applies a migration
The runner follows the Mongo runner's model:
- It takes MySQL's
GET_LOCK for the whole apply, on one connection, and releases it in a finally. A failed release never hides the error that ended the run.
- For each space, it runs each operation with its pre- and postchecks. An operation whose postchecks already hold is skipped, which is what makes a re-run resume.
- It verifies that space's schema.
- Only then does it write that space's marker and ledger entry, in one transaction.
An error thrown partway through keeps its own code and advice, and gains failingSpace and databaseUnchanged. Only an error without a structured code, such as a dropped socket, becomes MIGRATION.EXECUTION_FAILED. If two runners start at once, the second waits for the lock, then fails cleanly with MIGRATION.MARKER_ORIGIN_MISMATCH, and the database is left untouched.
What the MySQL planner does
The planner is deliberately narrow:
- It plans: creating and dropping tables, columns, indexes, unique constraints and foreign keys.
- It refuses everything else, as a planner conflict that says the change isn't supported on MySQL yet. That covers changing a column's type, nullability or default; primary key changes; CHECK constraints; expression indexes; and renames, conversions and backfills.
- It refuses MySQL limits before apply, not halfway through: names longer than 64 characters, and an auto-increment column that isn't the first column of a key.
- It handles InnoDB's own foreign-key indexes. Dropping a foreign key also drops the index InnoDB created for it, unless the contract keeps an index of that name. It never drops an index that a kept foreign key still needs.
Other shared changes
db sign's order is the adapter's choice. Postgres and SQLite keep their single transaction for the lock, the marker table and the marker writes, exactly as before. An adapter may provide the new optional holdMarkerLock. MySQL does, so it takes GET_LOCK, creates the marker table, and writes markers in a transaction, all under the lock. That's needed because creating a table commits on MySQL.
- Each target names its marker location once, on its control adapter, and the CLI and verifier messages read it from there. This fixes a real bug: Postgres users were told the marker lives in
_prisma_marker when it is prisma_contract.marker.
SqlPlanTargetDetails.schema is optional. SQLite no longer fakes the schema name 'main'. One side effect: SQLite messages that name an object by its storage name now say user where they said main.user.
For people who build their own target
Upgrade notes under upgrade-instructions/pending/ cover:
- the new required
markerLocation on control adapters and family instances;
- the optional
holdMarkerLock;
SqlPlanTargetDetails.schema becoming optional.
What this slice found
coupling.md marks these shared assumptions fixed here:
- the family-wide rollback promise;
db sign creating the marker table inside the marker transaction;
- the marker lock assumed to end with the transaction;
- a required schema name;
- hard-coded marker table names.
deferred.md records what was found but left for later:
- the migration CLI loads the target and adapter twice when it runs a
migration.ts;
- Mongo and MySQL each carry their own copy of the per-space loop;
- an internal runner step is exposed on a public interface;
- each target has its own error code for a missing control stack.
Verification
All pass locally:
pnpm build, pnpm typecheck, pnpm lint, pnpm lint:deps
pnpm fixtures:check, pnpm check:error-reference, pnpm check:upgrade-coverage --mode pr
- the MySQL, CLI, SQL family and migration-tools package tests, the MySQL ones against a local server
- the integration files for
db sign, and the new MySQL CLI journey (plan, migrate, verify, sign, add and drop a column)
The live tests cover:
- a two-space apply whose second space fails, then a re-run that converges;
- two runners at once;
- the lock released after both success and failure;
- re-pointing a relation;
- dropping a relation while keeping its column.
The local server is MySQL 9.6. CI runs MySQL 8.4.
Alternatives considered
- A fixed
applyAtomicity: 'all-spaces' | 'per-space' field on every target. It was built and then removed. Its only reader repeated what the failure already says, and 'per-space' wrongly suggested each space applies all or nothing. Only the marker write is atomic; operations that ran stay applied.
- Creating the marker table outside the lock for every target. It's simpler, but on a fresh Postgres database two
db sign runs at once could collide, which the lock used to prevent.
- Building ADR 037's compensation and commit groups now. That's real work for later. This slice keeps the narrower promise every target can keep: say what stayed, and make a re-run converge.
Refs: TML-3704
Agent: pangloss-22
🤖 Generated with Claude Code
Summary by CodeRabbit
- New Features
- MySQL now supports migration planning, generated migration files, applying and verifying schema changes, and signing contracts.
- Migration guidance identifies the marker table or collection used by each database target.
- Bug Fixes
- Migration failures identify the affected contract space and clarify whether database changes remain.
- MySQL migration runs can resume after partial progress; transactional targets roll back changes across spaces when an apply fails.
- Documentation
- Updated migration and error guidance to explain database-specific failure and retry behavior, including MySQL’s partial-progress behavior.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
TargetMigrationsCapability gains a required applyAtomicity ('all-spaces' or
'per-space') and markerLocation. Postgres and SQLite state 'all-spaces',
Mongo 'per-space'. Every doc comment that promised a failed apply rolls
back every space now says it of 'all-spaces' targets only. When a
per-space apply fails after changing the database, the CLI names the
space it stopped at and says the spaces before it stay applied.
Shared fixes the MySQL target needs: signSpaces creates the marker table
before the transaction that locks and writes markers; the lockMarker doc
lets the adapter decide how long its lock lives; SqlPlanTargetDetails.schema
is optional and SQLite no longer fakes 'main'; the orphan-marker messages
name the target's marker location. The db sign help no longer promises one
transaction, which Mongo never gave.
Refs: TML-3704
Signed-off-by: willbot <[email protected]>
Signed-off-by: Will Madden <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
…r lock
initMarker writes with INSERT ... ON DUPLICATE KEY UPDATE in the target's
own control SQL. updateMarker has no RETURNING to read, so it reads and
locks the row with FOR UPDATE inside the caller's transaction and writes
it only when it still holds the expected hash. lockMarker takes GET_LOCK
under a name derived from the database, and withTransaction releases it
with RELEASE_LOCK on the same connection whether the transaction commits
or rolls back.
Refs: TML-3704
Signed-off-by: willbot <[email protected]>
Signed-off-by: Will Madden <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
…time
The MySQL planner diffs the contract's schema against the live one and
plans creating and dropping tables, columns, indexes, unique constraints
and foreign keys, with backtick-quoted DDL. Foreign keys are added after
every table exists and dropped first. Every other change (a column's
type, nullability or default, a primary key, a CHECK constraint, a
required column with no default) and every statement such as a rename is
refused with a conflict that says it is not yet supported on MySQL.
migration.ts is written as calls on a MySQL migration class, which the
facade exports from @internal/mysql/migration.
MySQL commits every DDL statement as it runs, so the runner applies one
space at a time: each operation with its pre- and postchecks, then the
space's schema check, then its marker and ledger entries in one
transaction. A failure names the space and says whether the database
changed; spaces before it stay applied and a second run finishes the
rest. The whole apply holds the marker lock, released on the same
connection. The descriptor states applyAtomicity 'per-space'.
The control adapter dispatches DDL by kind instead of instanceof, since
the migration CLI can load the target module twice.
Live tests (skipped without MYSQL_URL) cover the example contract through
the CLI (migration plan, db migrate, db verify, db sign), adding and
dropping a column, a failed second space and its re-run, and the lock.
Refs: TML-3704
Signed-off-by: willbot <[email protected]>
Signed-off-by: Will Madden <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
ADR 212, the Migration System and MongoDB Family docs and the error
reference no longer promise that a failed apply rolls back every space:
they say it of the targets that state 'all-spaces', and describe the
per-space model MySQL and Mongo state. The stale executeAcrossSpaces name
in ADR 212 is gone. The error reference documents
MIGRATION.MARKER_LOCK_TIMEOUT and MIGRATION.MYSQL_CONTROL_STACK_MISSING.
The MySQL READMEs describe the planner, runner, marker writes and lock;
the coupling register records rows 4, 5, 6, 13 and 22 as fixed. Upgrade
instructions cover the new required capability fields and the
verifyContractSpaces markerLocation input.
Refs: TML-3704
Signed-off-by: willbot <[email protected]>
Signed-off-by: Will Madden <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
The single-import-root check refuses a workspace import in a journey
test, so the MySQL config lives beside the SQLite one in the journey
fixtures, with its database URL filled in by the test.
Refs: TML-3704
Signed-off-by: willbot <[email protected]>
Signed-off-by: Will Madden <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
…it left
TargetMigrationsCapability no longer carries applyAtomicity. Its only
reader was the CLI's failure report, which the runner's failure meta
already answers: failingSpace and databaseUnchanged state per run what a
failed apply left. The runner type, control-instances, CLI docs, ADR 212
(with a dated note), and the Migration System and MongoDB Family docs
now say that a target whose DDL is transactional rolls back and reports
databaseUnchanged: true, and that otherwise the operations that already
ran stay applied. The upgrade fragments drop the field.
Refs: TML-3704
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: willbot <[email protected]>
Signed-off-by: Will Madden <[email protected]>
A failed apply's headline is the runner's own message again, as on main,
so Postgres and SQLite output does not change. When the failure says the
database changed (databaseUnchanged: false), one line under it says that
changes made before the failure stay in the database. It no longer
claims anything about other spaces or advises running the command again;
each failure code keeps its own advice. A new test drives runMigration
with a stub runner, so removing the call fails a test.
Refs: TML-3704
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: willbot <[email protected]>
Signed-off-by: Will Madden <[email protected]>
signSpaces again takes the marker lock, creates the marker table and
writes the markers in one transaction, as on main, so Postgres and
SQLite behave as before and concurrent first-time signs stay serialised.
A control adapter whose DDL ends an open transaction provides the new
optional holdMarkerLock: signSpaces then creates the marker table under
that lock, outside the transaction, and writes the markers in a
transaction inside it. MySQL provides it with GET_LOCK and RELEASE_LOCK.
Refs: TML-3704
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: willbot <[email protected]>
Signed-off-by: Will Madden <[email protected]>
lowerToExecuteRequest dispatches a MySQL DDL node with ast.accept, as the
Postgres and SQLite adapters do, instead of checking kind and casting to
MysqlCreateTable. Dispatching through a method on the node works when
the migration CLI loads the node from another copy of the module. The
bootstrap builders now return MySQL DDL nodes, so no cast is needed.
Refs: TML-3704
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: willbot <[email protected]>
Signed-off-by: Will Madden <[email protected]>
markerLocation moves off TargetMigrationsCapability. Each control adapter
already passed its marker table's name to the framework's marker read
errors; it now names it once, as markerLocation, and the SQL and Mongo
family instances expose the adapter's value on ControlFamilyInstance.
The orphan-marker message of db init and db update reads it from the
family instance, so a target with markers but no migrations can name
them too. Postgres's descriptor literal is gone, and Mongo's two strings
become one, _prisma_migrations. verifyContractSpaces keeps its
markerLocation input. The upgrade fragment says which interfaces gained
the field.
Refs: TML-3704
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: willbot <[email protected]>
Signed-off-by: Will Madden <[email protected]>
When a foreign key's columns have no index, InnoDB makes one with the
key's name and keeps it after ALTER TABLE ... DROP FOREIGN KEY. The
planner now drops that index after the key when the destination keeps
no index of that name, so strict verification finds no stray index.
It also refuses, as a conflict before anything applies, to drop an
index that a foreign key of the destination uses when no other index
can take over, which MySQL would reject mid-apply. Planner tests and
live tests cover both.
Refs: TML-3704
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: willbot <[email protected]>
Signed-off-by: Will Madden <[email protected]>
Releasing the marker lock no longer replaces the outcome it follows: a
failed RELEASE_LOCK is dropped when the work it guarded failed, by
throwing or by returning a failure, and reported only when the work
succeeded. The runner, holdMarkerLock and withTransaction share this
rule, and a failed ROLLBACK no longer hides the error that caused it.
An error thrown while a space applies (a check query, introspection,
the ledger insert, COMMIT, a lost connection) now becomes a runner
failure with failingSpace and databaseUnchanged, as a returned failure
does. A MIGRATION error keeps its code; any other is reported as
MIGRATION.EXECUTION_FAILED with its own code in errorCode. The space's
progress is tracked as it goes, so databaseUnchanged is false once a
statement ran or a COMMIT was attempted. Tests inject a throwing driver.
Refs: TML-3704
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: willbot <[email protected]>
Signed-off-by: Will Madden <[email protected]>
…n time
MySQL rejects an identifier longer than 64 characters (error 1059) and a
table whose AUTO_INCREMENT column does not lead a key (error 1075), but
only when the statement runs, after earlier statements of the space have
committed. The planner now refuses both as conflicts before anything
applies: every table, column, index and constraint name a plan creates
is checked against the limit, and an autoincrement column must be the
first column of the primary key or of a unique constraint.
Refs: TML-3704
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: willbot <[email protected]>
Signed-off-by: Will Madden <[email protected]>
On MySQL the runner creates the marker and ledger tables with DDL that
commits, so a failure right after it still reports databaseUnchanged:
true. The failure meta's doc, the SQL runner doc, the Migration System
doc and the error reference now say that creating those tables does
not count as changing the database.
Refs: TML-3704
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: willbot <[email protected]>
Signed-off-by: Will Madden <[email protected]>
Postgres and SQLite check the app space's schema inside their one
transaction. The MySQL runner checks every space before it writes that
space's marker, because the marker write is where a space counts as
applied, and it uses the strictness the caller passes. The Migration
System doc, the runner's doc and the target README now say so.
Refs: TML-3704
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: willbot <[email protected]>
Signed-off-by: Will Madden <[email protected]>
…ports
Two runners start the same plan on their own connections at once. The
first takes the marker lock and applies; the second waits on GET_LOCK,
then finds the marker no longer at its plan's origin and refuses with
MIGRATION.MARKER_ORIGIN_MISMATCH, reporting databaseUnchanged: true.
The marker ends at the destination and the lock is free.
Refs: TML-3704
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: willbot <[email protected]>
Signed-off-by: Will Madden <[email protected]>
The live migration tests talk to a MySQL server, so the package default of 500 ms is too short on a loaded machine or on CI. Their describe block now uses timeouts.databaseOperation, as the slice 2a live tests do.
Refs: TML-3704
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: willbot <[email protected]>
Signed-off-by: Will Madden <[email protected]>
The CLI no longer adds a line when a failed apply changed the database.
The runner's own why already says what stayed ("The operations that ran
before the failure stay applied."), on MySQL and on MongoDB, so
runMigration returns the runner's failure as it is, for every target,
and the report helper is gone. The tests now check that the message and
why pass through unchanged whether or not the database changed.
Refs: TML-3704
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: willbot <[email protected]>
Signed-off-by: Will Madden <[email protected]>
The static applyAtomicity field was removed after review; each runner
states per run what a failed apply left, and db sign's order is the
adapter's choice.
Refs: TML-3704
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: willbot <[email protected]>
Signed-off-by: Will Madden <[email protected]>
Re-pointing Post.authorId from User to Admin drops and adds a foreign
key with the same name. When the column has no index of its own, the
planner also drops the index InnoDB made for the old key, and the check
for an index a foreign key uses refused that drop, because the new key
has the same name. That plan worked before the fix for InnoDB's
leftover index.
InnoDB's index is now dropped right after its key, before any key is
added, so a new key on the same columns makes its own index and MySQL
never refuses the drop. The check for that drop protects only keys the
plan keeps. A planner test and a live test, which verifies strictly,
cover the re-point.
Refs: TML-3704
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: willbot <[email protected]>
Signed-off-by: Will Madden <[email protected]>
An error thrown while a space applied was turned into a runner failure,
which kept its message and why but dropped its fix, next actions and
docs link, and reported any non-migration code as
MIGRATION.EXECUTION_FAILED. A CONTRACT.MARKER_ROW_CORRUPT then read as a
failed SQL step.
The runner now rethrows a structured error as it is, adding failingSpace
and databaseUnchanged to its meta, and rethrows an InternalError
unchanged. Only an error without a structured code, such as a driver's
socket error, becomes MIGRATION.EXECUTION_FAILED, with its own code in
meta.errorCode. The error reference says so.
Refs: TML-3704
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: willbot <[email protected]>
Signed-off-by: Will Madden <[email protected]>
MySQL had two ways to hold the marker lock: lockMarker, whose lock the
adapter's withTransaction released through a WeakSet, and
holdMarkerLock. Since db sign uses holdMarkerLock on MySQL, the first
ran only in tests. withMarkerLock in the target now takes the lock, runs
the work and releases it on the same connection, keeping the work's
failure over a failed release. The runner and holdMarkerLock both use
it. lockMarker takes no lock, because the lock is already held around
the transaction, and withTransaction is a plain transaction again.
Coupling row 6 is updated.
Refs: TML-3704
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: willbot <[email protected]>
Signed-off-by: Will Madden <[email protected]>
A runner failure carries failingSpace only in its payload, so the human
output never said which space stopped. When the space is not the
application's own, the CLI now adds "The apply stopped in contract
space "<space>"." to the runner's why. It reads the generic failingSpace
fact and names no target. A failure in the application's space reads as
before, so Postgres and SQLite output for a single-space apply does not
change. ADR 212 and the error reference say so.
Refs: TML-3704
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: willbot <[email protected]>
Signed-off-by: Will Madden <[email protected]>
…nd holdMarkerLock
The marker-location fragment detected only classes that implement a
control adapter. Its detection now finds an adapter written as an
object literal or returned by a factory, and a third-party
ControlFamilyInstance, when the file has no markerLocation, and the
prose shows both. It also describes the new optional holdMarkerLock,
which a target whose DDL ends a transaction gives its SQL control
adapter so db sign creates the marker table under the lock.
Refs: TML-3704
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: willbot <[email protected]>
Signed-off-by: Will Madden <[email protected]>
Dispatching through the node's visitor removed the structured refusal
for an unknown DDL node: a node without accept, or one whose accept
calls a visitor method MySQL lacks, failed with a TypeError. Both now
fail with RUNTIME.DDL_UNSUPPORTED, naming the node's kind. A MySQL node
still lowers through its visitor, from any copy of the module.
Refs: TML-3704
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: willbot <[email protected]>
Signed-off-by: Will Madden <[email protected]>
The marker lock helpers lived in the target's control-tables entrypoint,
though they are not tables. They move to a new ./marker-lock entrypoint
in the migration plane, which the control adapter and the live tests
import. The lockMarker doc no longer calls it the lock the migration
runner holds: it is the lock db sign takes, runners take the same lock
themselves, and a target that already holds it around the transaction
does nothing there.
Refs: TML-3704
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: willbot <[email protected]>
Signed-off-by: Will Madden <[email protected]>
coderabbitai
Bot
commented
Oct 22, 2026
•
edited
Loading
Uh oh!
There was an error while loading. Please reload this page.
|

No actionable comments were generated in the recent review. 🎉
ℹ️ Recent review info
-
⚙️ Run configuration
-
- Source mode: Auto
- Repository: prisma/orm
- Branch: main
- File: .coderabbit.yml
- Commit: c4ad961
- Layers: Repository YAML
- Review profile: CHILL
- Plan: Advanced
- Run ID:
cfd9c232-5b18-4d82-bdd8-773650a0a293
📥 Commits
-
Reviewing files that changed from the base of the PR and between 971974a and c06ac77.
⛔ Files ignored due to path filters: 7
-
pnpm-lock.yaml is excluded by !**/pnpm-lock.yaml
projects/mysql-poc/coupling.md is excluded by !projects/**
projects/mysql-poc/deferred.md is excluded by !projects/**
projects/mysql-poc/design-notes.md is excluded by !projects/**
projects/mysql-poc/plan.md is excluded by !projects/**
projects/mysql-poc/slices/mysql-migrations/spec.md is excluded by !projects/**
projects/mysql-poc/spec.md is excluded by !projects/**
📒 Files selected for processing: 3
-
architecture.config.json
docs/reference/error-reference.md
packages/3-targets/sqlite/2-adapter/test/migrations/runner.connection-errors.test.ts
Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 8 remain after this review.
📝 Walkthrough
-
The change adds MySQL migration planning, rendering, and execution, with marker and ledger persistence protected by a session-level lock. Shared interfaces now expose marker locations and describe target-specific rollback and resume behavior. The MySQL migration API is available through target and facade exports.
Changes: MySQL Migration Support and Marker Contracts
| Layer / File(s) |
Summary |
Shared marker contracts and target details packages/1-framework/..., packages/2-sql-family/..., packages/2-mongo-family/..., packages/3-targets/{mongo,postgres,sqlite}/..., packages/3-tooling/..., upgrade-instructions/... |
Control interfaces and adapters expose markerLocation. SQL signing supports an optional external marker lock. SQL plan details make schema optional, and SQLite target details no longer include schema: 'main'. |
MySQL planning and rendering packages/3-targets/mysql/1-target/src/core/migrations/*, packages/3-targets/mysql/1-target/test/migrations/*, packages/3-targets/mysql/9-facade/test/migrations/planner* |
The MySQL target adds schema-diff planning, operation calls, SQL and TypeScript rendering, and conflict checks for unsupported or incompatible changes. |
MySQL marker storage and locking packages/3-targets/mysql/1-target/src/core/marker-lock.ts, packages/3-targets/mysql/2-adapter/src/core/migrations/*, packages/3-targets/mysql/2-adapter/test/* |
The adapter adds marker insertion, initialization, compare-and-swap updates, ledger writes, DDL lowering, and session-level marker locking. |
Per-space execution and failure reporting packages/3-targets/mysql/1-target/src/core/migrations/runner.ts, packages/1-framework/3-tooling/cli/..., packages/3-targets/mysql/9-facade/test/migrations/migrate.live.test.ts, docs/architecture docs/*, docs/reference/error-reference.md |
The runner applies and verifies spaces in order, then writes their markers and ledger entries. Failures report the failing space and database-change status. Documentation describes transactional and non-transactional target behavior. |
Exports and integration coverage architecture.config.json, packages/3-targets/mysql/*/README.md, packages/3-targets/mysql/9-facade/*, test/integration/* |
MySQL migration and marker-lock exports are wired into the target and facade packages. CLI integration coverage exercises MySQL migration, verification, signing, and destructive-change handling. |
Priority: ➖ Normal
Estimated code review effort: 4 (Complex) | ~75 minutes
Change: Feature
Sequence Diagram(s)
sequenceDiagram
participant MysqlMigrationPlanner
participant SqlMigrationRunner
participant MysqlControlAdapter
participant MySQLDatabase
MysqlMigrationPlanner->>SqlMigrationRunner: provide migration plan
SqlMigrationRunner->>MysqlControlAdapter: acquire marker lock
SqlMigrationRunner->>MySQLDatabase: apply and verify each space
SqlMigrationRunner->>MysqlControlAdapter: write marker and ledger for verified space
SqlMigrationRunner->>MysqlControlAdapter: release marker lock
Loading
Suggested reviewers: sevinf
Merge Risk: ⚪ Minimal · up to c06ac
-
The reviewed changes introduce no identified merge-blocking risk.
Pre-merge checks: 4 · 1
-
Failed checks: 1 warning
| Check name |
Status |
Explanation |
Resolution |
| Docstring Coverage |
 |
Docstring coverage is 38.32% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 107 functions across 51 files. (2 skipped… |
Write docstrings for the functions missing them to satisfy the coverage threshold. |
Passed checks: 4 passed
-
| Check name |
Status |
Explanation |
| Description Check |
 |
Check skipped - CodeRabbit’s high-level summary is enabled. |
| Title check |
 |
The title clearly summarizes the main changes: MySQL migration, verification, and signing support, plus reporting of what failed migrations leave applied. |
| Linked Issues check |
 |
Check skipped because no linked issues were found for this pull request. |
| Out of Scope Changes check |
 |
Check skipped because no linked issues were found for this pull request. |
Full details: Docstring Coverage
-
Explanation
Docstring coverage is 38.32% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 107 functions across 51 files. (2 skipped: 2 unsupported.)
Resolution
Write docstrings for the functions missing them to satisfy the coverage threshold.
✨ Finishing Touches: 💡 1
-
📝 Generate docstrings: 💡
-
- Commit to this branch
- Create a new PR
🧪 Generate unit tests (beta)
-
- Commit to this branch
- Create a new PR
- Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
Comment @coderabbitai help to get the list of available commands.
|
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
size-limit report 📦
| Path |
Size |
| postgres / no-emit |
264.13 KB (+0.04% 🔺) |
| postgres / emit |
231.72 KB (+0.03% 🔺) |
| mongo / no-emit |
225.13 KB (0%) |
| mongo / emit |
182.9 KB (0%) |
| cf-worker / no-emit |
327.23 KB (+0.03% 🔺) |
| cf-worker / emit |
291.12 KB (+0.03% 🔺) |
|
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
…sql-migrations-verify-sign
Signed-off-by: willbot <[email protected]>
Signed-off-by: Will Madden <[email protected]>
# Conflicts:
# packages/3-targets/mysql/1-target/package.json
# packages/3-targets/mysql/9-facade/package.json
# test/integration/package.json
pkg-pr-new
Bot
commented
Oct 22, 2026
•
edited
Loading
Uh oh!
There was an error while loading. Please reload this page.
|
Open in StackBlitz
@prisma/orm-extension-arktype-json
npm i https://pkg.pr.new/@prisma/orm-extension-arktype-json@30841
@prisma/orm-extension-middleware-cache
npm i https://pkg.pr.new/@prisma/orm-extension-middleware-cache@30841
@prisma/orm-extension-paradedb
npm i https://pkg.pr.new/@prisma/orm-extension-paradedb@30841
@prisma/orm-extension-pgvector
npm i https://pkg.pr.new/@prisma/orm-extension-pgvector@30841
@prisma/orm-extension-postgis
npm i https://pkg.pr.new/@prisma/orm-extension-postgis@30841
@prisma/orm-extension-supabase
npm i https://pkg.pr.new/@prisma/orm-extension-supabase@30841
@prisma/orm-family-mongo
npm i https://pkg.pr.new/@prisma/orm-family-mongo@30841
@prisma/orm-family-sql
npm i https://pkg.pr.new/@prisma/orm-family-sql@30841
@prisma/orm-framework
npm i https://pkg.pr.new/@prisma/orm-framework@30841
@prisma/orm-mongo
npm i https://pkg.pr.new/@prisma/orm-mongo@30841
@prisma/orm-postgres
npm i https://pkg.pr.new/@prisma/orm-postgres@30841
@prisma/orm-sqlite
npm i https://pkg.pr.new/@prisma/orm-sqlite@30841
@prisma/orm-target-mongo
npm i https://pkg.pr.new/@prisma/orm-target-mongo@30841
@prisma/orm-target-postgres
npm i https://pkg.pr.new/@prisma/orm-target-postgres@30841
@prisma/orm-target-sqlite
npm i https://pkg.pr.new/@prisma/orm-target-sqlite@30841
@prisma/orm-toolchain
npm i https://pkg.pr.new/@prisma/orm-toolchain@30841
commit: c06ac77
|
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
Will, 2026-10-23: examples/prisma-8-demo-mysql with the public
@prisma/orm-mysql packages after slice 4, and run it against MariaDB in
the MariaDB slice.
Refs: TML-3723
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: willbot <[email protected]>
Signed-off-by: Will Madden <[email protected]>
Uh oh!
There was an error while loading. Please reload this page.
Thegreatsura
pushed a commit
to Thegreatsura/prisma
that referenced
this pull request
Nov 20, 2026
…ests in CI (prisma#31108)
## Linked issue
Closes [TML-3697](https://linear.app/prisma-company/issue/TML-3697) and
[TML-3889](https://linear.app/prisma-company/issue/TML-3889). This
closes the Linear project [MySQL proof of
concept](https://linear.app/prisma-company/project/mysql-proof-of-concept-da2bc4144a89).
It follows prisma#31091, the last change of the project.
## At a glance
The one completion condition that was not met, now run in CI on both
databases:
```ts
// examples/prisma-8-demo-mysql/test/plan-from-empty.test.ts
// an empty migrations directory, the contract of the committed first migration
const result = await prisma(project, ['migration', 'plan', '--name', 'init', '--json'])
expect(planned.ops).toEqual(committed.ops)
```
And the MySQL tests in `test/integration`, which no CI job ran, now run
in the merge queue: the integration job starts a MySQL 8.4 server, and a
missing server fails the job.
## Decision
1. **The MySQL proof of concept is closed.** `projects/mysql-poc/` is
deleted. Nothing outside it referred to it.
2. **Its last unmet condition is met.** Each example app has a test that
plans the first migration from an empty project with the real CLI and
compares the planned operations with the committed migration.
3. **The MySQL integration tests run in CI.** Four files under
`test/integration` skipped themselves on every run, because the
integration job started no MySQL server. The job now starts one, in the
merge queue and in the on-demand workflow, and a new test fails in CI
when `MYSQL_URL` is not set.
4. **The integration suite runs once.** Its `packaging` test project
inherited the shared file pattern and ran every file a second time,
serially. It now runs only the three packaging tests. On-demand runs on
this branch:
[before](https://github.com/prisma/orm/actions/runs/44625631989), 1,537
file runs and 18 to 26 minutes a shard;
[after](https://github.com/prisma/orm/actions/runs/44631196075), 784 and
5 to 12 minutes.
5. **The final retro is in `drive/retro/README.md`,** as a short list
that links to three new failure modes and five checklist lines.
6. **The root README lists MySQL and MariaDB** as proofs of concept, as
it lists SQLite. It said "MySQL follows after SQLite".
## Reviewer notes
- **The ORM fix for writes MySQL refuses is not part of the project.**
MySQL refuses an update or delete whose filter reads the table it
writes, with an error that says what to do. The fix in the shared ORM
client is [TML-3880](https://linear.app/prisma-company/issue/TML-3880).
The spec's question, what a second SQL database costs and where shared
code assumes Postgres, is answered without it, and the spec accepts a
clear refusal for a feature a target does not support.
- **The integration job now starts a MySQL server in every shard.** All
four files passed against a live MySQL 8.4 before any change. No
integration test uses MariaDB, so that server is not started there. Both
runs linked above show the four MySQL files and the server check
passing.
- **Three small doc corrections ride along:** the MySQL driver README
said "3.5.4 or later" where the package is pinned to 3.5.4 and carried
two measured timings, now removed; the target README says why `String`
is `varchar(191)`; the adapter README counted three overridable methods
where there are four.
- **The scorecard does not cover MySQL or MariaDB.** It has one column
per database and 593 rows, each needing a verdict from an integration
test. The README now says which databases it covers.
- **The project's working notes are deleted, not moved.** Research
measurements and surveys do not belong in package READMEs or ADRs. The
decisions they led to are in the ADRs written during the project.
## Completion conditions
From the project's spec:
| Condition | State | Evidence |
| --- | --- | --- |
| The spec's commands and calls succeed on MySQL 8.4 and MariaDB 10.11
in CI | Met with this pull request | Emit: the Fixtures job. Plan from
an empty project: the new example tests. Migrate, verify, sign, create,
read with an include, update, upsert, delete: both example apps in Test
Examples, and the live suites in Package Tests. Green on `main`:
[merge-queue run for
a181ff2](https://github.com/prisma/orm/actions/runs/44402538308) |
| Every row of the register of Postgres assumptions is fixed or filed,
and every breaking one is fixed | Met | Table below |
| No target, adapter, driver or facade code outside
`packages/3-targets/<db>/`, and the docs describe the layout | Met |
`architecture.config.json`; `scripts/lint-target-layering.mjs`, run by
`lint:deps`; ADR 278 and ADR 325 |
| Both example apps run in CI through the public packages | Met | Each
depends only on `@prisma/orm-mysql` or `@prisma/orm-mariadb`; 11 of 11
tests each in Test Examples |
| An ADR records the layout; ADR 212 and the Migration System doc say
what a failed migration left | Met | ADR 278; ADR 212; `7. Migration
System.md` |
| The release plan's row is marked done and the follow-up issues are
listed | Met | The row reads done on the `planning/prisma-8-ga` branch,
which is not on `main`. Issues: listed below |
From the team's checklist: build, `lint:deps` and `fixtures:check` are
green in the run above. Every review thread on all twelve pull requests
of the project is resolved. No ADR decision is left unrecorded: the 83
decisions in the spec and design notes were mapped to their homes, and
the seven with none were written into ADR 157, ADR 164, ADR 212, ADR 325
and the public READMEs in prisma#31091.
### The register of Postgres assumptions
31 rows. 14 were fixed in the project's pull requests (prisma#30836, prisma#30841,
prisma#30863, prisma#30893, prisma#30927, prisma#31058).
| Rows | Outcome |
| --- | --- |
| 8, 12, 14, 15, 20, 21, 23, 24, 27, 30, 31 | Filed: TML-3856, TML-3851,
TML-3857, TML-3858, TML-3859, TML-3831, TML-3854, TML-3857, TML-3853,
TML-3852, TML-3855 |
| 18 | MySQL refuses the write with a clear error (prisma#31091). The ORM fix
is TML-3880 |
| 10, 11 | Not defects. `distinctOn` and the Postgres-only lock
strengths sit under the `postgres` capability group by the rule ADR 261
records. Row locking on MySQL is TML-3850 |
| 25, 26, 29 | Not defects. The namespace factory owns enum members;
only Postgres calls `sqlBaseName`; row 29 is the same finding as row 30
|
## File classification
Every file under `projects/mysql-poc/` is a working file of the project
and is deleted: the spec, the plan, the README, the handover, the slice
specs and plans, the research notes, the design notes, the register and
the list of deferred work. None is moved as a file. The decisions they
led to are in the ADRs written during the project, and the open work is
in the issues below.
## Follow-ups
In the Linear project "MySQL proof of concept" unless marked as
existing:
- **MySQL and MariaDB features:** TML-3850 row locks, TML-3866
`onConflict: 'skip'`, TML-3869 MariaDB `RETURNING` by statement kind,
TML-3870 MariaDB JSON and Boolean data types, TML-3851 `SET` as a raw
column, TML-3790 convenience types (existing), TML-3831 `orm init`
targets (existing), TML-3859 Prisma 7 reader and native enums.
- **Correctness:** TML-3880 writes that read their own table, TML-3867
upsert with an unlisted unique index, TML-3856 upsert into a table named
`excluded`, TML-3871 key columns whose codec loses precision, TML-3874
names starting `__prisma_`, TML-3841 `having` on a mean (existing).
- **Errors and messages:** TML-3875, TML-3857, TML-3863, TML-3883,
TML-3885, TML-3887, TML-3852, TML-3858.
- **Shared code and structure:** TML-3854, TML-3855, TML-3860, TML-3861,
TML-3862, TML-3864, TML-3865, TML-3882, TML-3888, TML-3853.
- **Reads and middleware:** TML-3872 streaming reads with includes,
TML-3873 budgets and lints on the ORM's own statements, TML-2333
(existing).
- **Outside this project's code:** TML-3886 the ORM cannot update a
field stored only on a variant's table, TML-3868 a report to the
`mariadb` package, TML-3777 an environment check for the MySQL driver
(existing).
- **CI:** none. TML-3889 is closed by this pull request.
## Testing performed
- Both example apps' full suites against live MySQL 8.4 and MariaDB
10.11: 12 of 12 each. The new test was shown to fail by changing a
column length in the scratch contract.
- The four MySQL files under `test/integration` and the new server check
against a live MySQL 8.4: 38 tests passed. With `CI` set and no
`MYSQL_URL`, the check fails.
- `pnpm lint:docs`, `pnpm lint:deps`, `pnpm lint:ratchets`, `pnpm
check:upgrade-coverage`; lint and typecheck of both example apps.
- A code review of this branch and a review of every doc line it adds.
## Skill update
None. No user-facing behaviour changes.
## Alternatives considered
- **One more slice for the ORM fix before closing.** It would not change
the project's answer, and the spec treats a clear refusal as acceptable
for an unsupported feature.
- **Keeping the register as a page in `docs/`.** Its open rows are
issues that will be closed one by one; a page listing them would go
stale. The Linear project lists them together.
- **Moving the project's research notes into the driver README and ADR
302.** One-run measurements, figures no test checks and surveys of other
libraries are research, not documentation.
## Checklist
- [x] All commits are signed off (`git commit -s`) per the
[DCO](../CONTRIBUTING.md#developer-certificate-of-origin-dco).
- [x] Tests are updated.
- [x] The **Skill update** section above is filled in.
Agent: aida-20
<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->
<!-- coderabbit-ai-generated:v1 -->
## Summary by CodeRabbit
* **Documentation**
* Clarified that SQLite, MySQL, and MariaDB are proof-of-concept
databases, and that the feature scoreboard does not yet cover MySQL or
MariaDB.
* Updated database guidance for MySQL string indexing, write statements
that read the same table, and driver error behavior.
* Refined project planning and retrospective guidance.
* **Tests**
* Added coverage for planning an initial migration in the MySQL and
MariaDB examples.
* Integration tests now run with a MySQL service in CI and verify that
the required connection is available.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->
---------
Signed-off-by: willbot <[email protected]>
Signed-off-by: Will Madden <[email protected]>
Reviewers
wmadden
wmadden approved these changes
Uh oh!
There was an error while loading. Please reload this page.
Assignees
No one assigned
Milestone
No milestone
Development
Successfully merging this pull request may close these issues.
Uh oh!
There was an error while loading. Please reload this page.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
|