Skip to content

feat(postgres)!: a PostgreSQL contract lists the capabilities it requires (optional, with a warning, until 8.0) - #31218

Merged
wmadden-electric merged 201 commits into
mainfrom
tml-3960-capabilities-by-database-version
Nov 27, 2026
Merged

wmadden-electric merged 201 commits into
mainfrom
tml-3960-capabilities-by-database-version

Conversation

@wmadden-electric

@wmadden-electric wmadden-electric commented Nov 25, 2026 •

Copy link
Copy Markdown
Contributor

At a glance

A capability is a named yes-or-no feature of the environment a PostgreSQL application runs in, such as sql.lateral (the database has lateral joins) or sql.interactiveTransactions (the connection can hold a transaction open). Until now every PostgreSQL contract was given the same fixed set, whatever the project ran on.

A contract now lists the capabilities it requires, from two lists Prisma exports: one for a PostgreSQL version, one for the driver's connection.

import { defineContract, postgres18, postgresDriver } from '@prisma/orm-postgres/contract-builder';

export const contract = defineContract({
  requiredCapabilities: [...postgres18, ...postgresDriver],
  // models…
});

A project that has not added the list yet keeps working until 8.0. When it runs prisma contract emit, it gets a warning with the exact text to add:

Your contract does not list the capabilities it requires, so it requires those of the newest PostgreSQL version and of the driver. Prisma 8.0 removes this default and requires the list. Write this in defineContract, with its import:

requiredCapabilities: [...postgres18, ...postgresDriver]

import { postgres18, postgresDriver } from '@prisma/orm-postgres/contract-builder';

The decision

The problem. A project could type-check a feature its environment lacks and find out when a query failed, for three reasons:

  • Every contract required the same capabilities, so it said nothing about the project's real database or connection.
  • Signing a database (prisma db sign, which records that a database matches a contract) never compared the database with the contract's capabilities.
  • When the client started, it added the capabilities of its own components to the contract's. A feature the contract did not require still ran.

The decision. Capabilities are a contract's dependencies. A database version or a connection provides them, and a contract requires them. Three rules follow:

  1. The author writes the list. requiredCapabilities is everything the contract requires. From 8.0 it is required and has no default, so every capability an error names is one the author can find in their own source.
  2. Signing checks the database. The commands that verify or change a database compare the server's version with a table of which PostgreSQL version provides which capability, and refuse a database that lacks one the contract requires.
  3. The client goes by the contract. It no longer adds capabilities of its own. A feature whose capability the contract does not require is unavailable. A capability the contract requires that the connection does not provide is a type error where the client is created, and a warning when it starts.

What breaks, and for whom. For a project on release candidate 25 that uses the PostgreSQL package's defineConfig: nothing, until 8.0 (the stopgap below). Three things do change:

  • A server older than PostgreSQL 15 is now refused by db sign, db verify, db init, db update and db migrate. Before, only init --probe-db warned about it.
  • A config that names the target, adapter and driver by hand, with the framework's defineConfig and not the PostgreSQL package's, gets no default. Its next emit writes a contract with no capabilities. The upgrade instructions detect this form and give the one line to add.
  • At 8.0 the list becomes required.

Why before 8.0. A required input and a change to which capabilities a contract contains would each need a major version afterwards.

How it works

Two lists

What Declared by Exported as
What each PostgreSQL version provides The PostgreSQL target, in a table of versions 15 to 18 postgres15 … postgres18
What the connection provides The driver postgresDriver

They are separate because they change separately. A project behind a connection pooler that cannot hold a transaction open keeps its database's list and leaves sql.interactiveTransactions out.

All four version lists are equal today: no feature Prisma supports needs more than PostgreSQL 15. So it does not matter yet which one a project spreads, and init writes the newest. A version's list is fixed for a major version of Prisma, and a test pins each one. A feature that needs a newer server arrives with a new list, such as postgres19, so a project that spreads postgres18 on a PostgreSQL 15 server is never refused by a later minor release.

A capability is removed by leaving it out: postgres18.filter((key) => key !== 'sql.jsonAgg'). TypeScript infers a type predicate from that comparison, so the key leaves the contract's type too, and the features that need it stop type-checking. A test covers it.

Where the list is written

  • A TypeScript contract: in defineContract, as above.

  • A contract in the Prisma schema language: in the config, because the schema language has no syntax for it yet. That syntax is designed and not built; the config entry is a stopgap for it.

    import { defineConfig as ormConfig, postgres18, postgresDriver } from '@prisma/orm-postgres/config';
    
    orm: ormConfig({
      contract: {
        path: './prisma/contract.prisma',
        requiredCapabilities: [...postgres18, ...postgresDriver],
      },
      db: { connection: process.env['DATABASE_URL']! },
    })
  • A project that keeps its Prisma 7 schema: prisma7Schema(path, { requiredCapabilities }).

prisma orm init writes the list into a new project. contract.json stores the capability keys in its capabilities field, in the same shape as before, and never a database version.

What is checked, and what the user sees

The database lacks a required capability. db verify, db sign, db init, db update and db migrate print one message and change nothing. They suggest no command, because none upgrades a server. The capability in this example does not exist; it stands for one that PostgreSQL would have from version 17:

Your contract requires database capabilities first available in PostgreSQL 17 (sql.notARealCapability), but this database runs PostgreSQL 15.4. Either upgrade the database, or remove them from your contract's required capabilities.

One limit: signing checks only the capabilities in its version table. It cannot tell a database capability it does not know from a connection capability, so the client reports those instead. The next pull request removes this limit (see "Not in this pull request").

The connection lacks a required capability. Where the application imports the contract's generated types, creating the client is a type error that names the capability. When the client starts, it logs a warning:

Your contract requires `sql.interactiveTransactions`, which this client's connection does not provide. Remove it from your contract's required capabilities, or connect with a driver that provides it.

It is a warning and not a failure because the client's checks at start never stop a running application; prisma db verify is the command that fails a deploy.

A feature's capability is not in the list. The call is refused, and it is a type error where TypeScript can see the need, as with transaction(). Every such refusal now has one form (there were six):

`transaction()` is unavailable: your contract declares no dependency on `sql.interactiveTransactions`. To enable it, add `sql.interactiveTransactions` to your contract's required capabilities.

Release candidate projects keep working

The goal: a project exactly as release candidate 25 left it, with its config, its contract source and its emitted contract.json unchanged, keeps type-checking, emitting and running after it upgrades, with warnings only. Three things make that so. All three are a stopgap, removed at 8.0.

  1. A missing list gets a default: the newest version's list and the driver's, which is what init writes. The CLI commands that load the contract's source, such as contract emit, print the warning shown at the top, with text that compiles when pasted. An application that loads its contract prints nothing.
  2. Retired flags are ignored. A release candidate's contract.json lists nine flags that nothing ever read: postgres.orderBy, postgres.limit, postgres.lateral, postgres.jsonAgg, postgres.returning, sql.enums, and three that extensions declared (pgvector.cosine, postgis.geometry, paradedb/bm25). The live flags sql.lateral and sql.jsonAgg are different keys and stay. This pull request stops emitting the nine, and the client's check skips them, so an old contract.json type-checks and starts without a warning. A retired flag written into a new list is refused.
  3. An old contract.json can still call transaction(). The default in point 1 only helps once a project emits again. Until then its contract.json has no sql.interactiveTransactions, because that flag is new. A contract that lists a retired flag can only have come from a release candidate, whose clients all offered transaction(), so it is allowed.

The proof. A test takes three projects' files from the tag v8.0.0-rc.25, byte for byte and pinned by checksum, and checks that each type-checks, emits with the warning, creates a client with no warning, and runs a query and a transaction(). It runs in pull request CI.

What a project does. Nothing before 8.0. To stop the warning: add the list as the warning shows, and run prisma contract emit. This pull request alone does not require signing databases again. #31203 will, because it makes a contract's signature cover its capability list.

Removing it. Every declaration that is part of the stopgap has "Prisma 8.0 removes" in its doc comment, so one search finds them all.

Changes to the framework

The framework packages must not know about any one database, so each change there is listed with why it is there:

  • A database that lacks capabilities, as data. A target returns its findings (capabilities a version lacks, a server older than supported, a version it could not read), and one framework function turns them into the message. It is in the framework so the message reads the same for every database and the CLI can recognise it. PostgreSQL in the text comes from the target.
  • The CLI gives no advice to change a refused database. After a failed verification the CLI normally suggests db update. It gives no such advice while the database is refused, because those commands are refused too.
  • init asks the database package for the config's contract: entry. The CLI writes prisma.config.ts and cannot know what a database's entry contains. An optional contractEntry member returns it, written with the tools migration files are already written with: an object that renders TypeScript source and lists the imports it needs. Without the member, init writes the path as before.
  • A lint limit rises from 139 to 143. The check that counts lines naming a database under the framework packages rises by four. The lines are in the CLI's two recorded PostgreSQL test contracts, which now import and list the two capability lists. No framework source line names a database.

API changes

  • @prisma/orm-postgres: defineContract, the config's contract entry and prisma7Schema take requiredCapabilities; the lists postgres15 to postgres18 and postgresDriver and the type RequiredCapabilities are added; postgresContractCapabilities builds a capability set from a list; the client's type checks its connection against the contract; and the init entrypoint returns the config's contract entry.

  • @prisma/orm-target-postgres: the target holds the table of capabilities by version, the server version range and the retired capabilities; its adapter and its control descriptors declare no capabilities, and the driver declares sql.interactiveTransactions.

  • @prisma/orm-family-sql: the client's check of its connection (StackProvides, capabilitiesNotProvided and the types around them), the one message for an unavailable feature (capabilityUnavailableMessage, which replaces missingCapabilityRemedy), the check for transaction(), the target hook databaseCapabilitiesNotProvided, and isSourceGivenNoCapabilities for the release candidate default.

  • @prisma/orm-framework: the types and the text function for a database that does not provide what a contract requires (DatabaseCapabilitiesNotProvided and the names around it), and the mismatch explanation that carries it.

  • @prisma/orm-toolchain: the init contribution's contractEntry member and its types (ContractEntryNode, ContractEntryInput, ConfigModuleExports).

  • @prisma/orm-extension-supabase: its client checks its connection against the contract, as the PostgreSQL client does, so its client and RoleBoundDb types change.

  • @prisma/orm-extension-pgvector, @prisma/orm-extension-postgis and @prisma/orm-extension-paradedb: each stops declaring a capability flag that nothing read, so its pack's type loses the capabilities field.

  • @prisma/orm-better-auth: prismaAdapter requires a client with transaction() only when the transaction option is on, and reads the client's retired capabilities so a release candidate contract is accepted.

  • @prisma/orm-target-mysql, @prisma/orm-target-mariadb and @prisma/orm-target-sqlite: each adapter's capability list gains sql.interactiveTransactions, which transaction() now requires of a contract.

  • @prisma/orm-mysql, @prisma/orm-mariadb and @prisma/orm-sqlite: each re-exports the SQL family's new capability-messages entry.

  • @prisma/orm-family-mongo, @prisma/orm-mongo and @prisma/orm-target-mongo: no export of theirs changes; each gains records, because their verification types include the cause of a schema difference, which gains a member (below).

Breaks against release candidate 25, each recorded in its package's api-breaks.json. These reach code written against the packages' lower-level types, such as tooling and extensions. Only the transaction() one touches code an application writes, and a release candidate's contract can still call it.

  • The cause of a schema difference can now be database-capabilities-not-provided, and the migration runner can fail with MIGRATION.DATABASE_CAPABILITIES_NOT_PROVIDED. Code that handles every cause or every code stops compiling until it handles the new one. This one cause is 321 of the 363 records, in every package whose types include it.
  • The PostgreSQL schema tree holds the server's version as the number serverVersionNumber in place of the text pgVersion.
  • The PostgreSQL adapter and the extension packs declare no capabilities.
  • transaction() is a type error for a contract that does not require sql.interactiveTransactions.
  • The Supabase contract's capabilities lose the retired flags.

Four things stay as release candidate 25 had them until 8.0, so that code written against it keeps compiling: the import paths of POSTGRES_MIN_SERVER_VERSION and postgresAdapterCapabilities, the fifth argument of renderLoweredSql, and the driver option of createExecutionContext. The last two are ignored. The API check cannot see a removed parameter, so a type test covers each.

Merge order

#31203 makes a contract's signature cover its capability list. The two pull requests can merge in either order. Whichever merges second regenerates the emitted fixtures.

Reading the diff

Most changed files are mechanical: about 450 configs, contracts, examples and tests gained the list. The substance is in:

  • packages/3-targets/postgres/1-target/src/core/server-version.ts and retired-capabilities.ts: the table of versions and the retired flags.
  • packages/3-targets/postgres/9-facade/src/contract/ and src/config/: the list, the default and the warning.
  • packages/2-sql-family/5-runtime/src/stack-capabilities.ts: the client's check.
  • packages/1-framework/1-core/framework-components/src/control/database-capabilities-not-provided.ts: the refusal as data.
  • packages/1-framework/3-tooling/cli/src/commands/init/ and packages/3-targets/postgres/9-facade/src/init/: what init writes.
  • test/e2e/framework/test/release-candidate-project.test.ts: the proof for release candidate projects.
  • docs/architecture docs/adrs/ADR 335 - A contract lists the capabilities it requires.md: the decision record.

Not in this pull request

  • Renaming what is stored. contract.json still calls the field capabilities, and keys still start with sql. or postgres.. The next pull request, before 8.0, renames the field to requiredCapabilities and prefixes each key by its provider (db. or conn.). Signing can then refuse any database capability its table does not know. It is separate because it is a pure rename across about 700 hand-written files.
  • MySQL, MariaDB, SQLite and MongoDB. They keep a fixed list from their adapter until each is built the same way. They are not at general availability.

Alternatives considered

  • Requiring the list at once. Every project on a release candidate would stop emitting until it added a line it has never seen, and its existing contract.json would stop type-checking.
  • A default kept for good. The requirements would not be in the author's source, and a default built from the newest version would change every such contract when a newer version is added.
  • A version number (databaseVersion: 17) in place of a list. It hid the connection's capabilities behind a default, and the number read as the exact version the database runs, when it is the oldest the contract supports.
  • One list per version that already includes the driver's capabilities. It would hide that the connection's capabilities are separate, which is what a project behind a pooler has to change.
  • One name for both sides (capabilities). "The contract's capabilities" reads as what the contract can do.
  • The client reads the database's capabilities when it connects. The client already compares the database's signature with the contract's at start, and signing has checked the capabilities by then. A second check would cost a query at every start for nothing.
  • A default for hand-built configs too. It would take a second temporary mechanism, in the target and the contract source builders, for a form the docs taught only to extension authors and to applications that assemble their config by hand.

Linear: TML-3960

Agent: heathcliff-78
🤖 Generated with Claude Code

wmadden-electric and others added 30 commits November 18, 2026 08:16
… and why connection flags stay out of the contract

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: willbot <[email protected]>
Signed-off-by: Will Madden <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: willbot <[email protected]>
Signed-off-by: Will Madden <[email protected]>
…andle; the contract also states connection requirements, checked when the client is created

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: willbot <[email protected]>
Signed-off-by: Will Madden <[email protected]>
…ture is the one check of the database; the stack is checked against the contract

Co-Authored-By: Claude Fable 5.2 <[email protected]>
Signed-off-by: willbot <[email protected]>
Signed-off-by: Will Madden <[email protected]>
…pabilities it requires; Prisma schema language syntax for them must be designed by the end of the project

Co-Authored-By: Claude Fable 5.2 <[email protected]>
Signed-off-by: willbot <[email protected]>
Signed-off-by: Will Madden <[email protected]>
…ws the fact; the target declares the database's capabilities by version

Co-Authored-By: Claude Fable 5.2 <[email protected]>
Signed-off-by: willbot <[email protected]>
Signed-off-by: Will Madden <[email protected]>
…not a named object per version

Co-Authored-By: Claude Fable 5.2 <[email protected]>
Signed-off-by: willbot <[email protected]>
Signed-off-by: Will Madden <[email protected]>
Co-Authored-By: Claude Fable 5.2 <[email protected]>
Signed-off-by: willbot <[email protected]>
Signed-off-by: Will Madden <[email protected]>
…sion' into worktree/capabilities-by-database-version-fb5e86
… list and where the signing check fits

Co-Authored-By: Claude Fable 5.2 <[email protected]>
Signed-off-by: willbot <[email protected]>
Signed-off-by: Will Madden <[email protected]>
…h cover capabilities

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: willbot <[email protected]>
Signed-off-by: Will Madden <[email protected]>
…ilities each provides

Co-Authored-By: Claude Opus <[email protected]>
Signed-off-by: willbot <[email protected]>
Signed-off-by: Will Madden <[email protected]>
…st the facade fills with its runtime adapter's and driver's

Co-Authored-By: Claude Fable 5.2 <[email protected]>
Signed-off-by: willbot <[email protected]>
Signed-off-by: Will Madden <[email protected]>
…nent knows

The database facts move to the target's version table. The runtime adapter and driver declare their own sets (empty today); the control adapter and driver declare nothing, since they migrate and do not run the application. The renderer checks locking clauses against the contract's capabilities.

Co-Authored-By: Claude Opus <[email protected]>
Signed-off-by: willbot <[email protected]>
Signed-off-by: Will Madden <[email protected]>
…nnection's capabilities

Co-Authored-By: Claude Opus <[email protected]>
Signed-off-by: willbot <[email protected]>
Signed-off-by: Will Madden <[email protected]>
…configured components'

Co-Authored-By: Claude Opus <[email protected]>
Signed-off-by: willbot <[email protected]>
Signed-off-by: Will Madden <[email protected]>
…risma schema contract

Co-Authored-By: Claude Opus <[email protected]>
Signed-off-by: willbot <[email protected]>
Signed-off-by: Will Madden <[email protected]>
…ity flags nothing reads

Co-Authored-By: Claude Opus <[email protected]>
Signed-off-by: willbot <[email protected]>
Signed-off-by: Will Madden <[email protected]>
…ma contract it emits

Co-Authored-By: Claude Opus <[email protected]>
Signed-off-by: willbot <[email protected]>
Signed-off-by: Will Madden <[email protected]>
Co-Authored-By: Claude Opus <[email protected]>
Signed-off-by: willbot <[email protected]>
Signed-off-by: Will Madden <[email protected]>
TypeScript contracts state it in defineContract; Prisma schema contracts state it in the config's contract entry.

Co-Authored-By: Claude Opus <[email protected]>
Signed-off-by: willbot <[email protected]>
Signed-off-by: Will Madden <[email protected]>
…hitecture map

Co-Authored-By: Claude Opus <[email protected]>
Signed-off-by: willbot <[email protected]>
Signed-off-by: Will Madden <[email protected]>
… the configured components'

Co-Authored-By: Claude Opus <[email protected]>
Signed-off-by: willbot <[email protected]>
Signed-off-by: Will Madden <[email protected]>
…nection's capabilities

Co-Authored-By: Claude Opus <[email protected]>
Signed-off-by: willbot <[email protected]>
Signed-off-by: Will Madden <[email protected]>
…d hands them to the contract source

Co-Authored-By: Claude Fable 5.2 <[email protected]>
Signed-off-by: willbot <[email protected]>
Signed-off-by: Will Madden <[email protected]>
… version rows and drivers

Co-Authored-By: Claude Fable 5.2 <[email protected]>
Signed-off-by: willbot <[email protected]>
Signed-off-by: Will Madden <[email protected]>
…e and gives them to its source

The version's row and the capabilities list are merged in order, keeping the flags that are on, and handed to defineContract, prismaContract and prisma7Contract alike. No control descriptor carries the row, so false turns a flag off the same way in every route. The facade's defineContract, defineConfig and prisma7Schema are built from the table so tests can use rows that differ. The table is named for what it holds and has one lookup. The renderer reads the locking flags from the contract it renders.

Co-Authored-By: Claude Opus <[email protected]>
Signed-off-by: willbot <[email protected]>
Signed-off-by: Will Madden <[email protected]>
… to write

Co-Authored-By: Claude Opus <[email protected]>
Signed-off-by: willbot <[email protected]>
Signed-off-by: Will Madden <[email protected]>
wmadden-electric and others added 5 commits November 27, 2026 20:16
Co-Authored-By: Claude Fable 5.2 <[email protected]>
Signed-off-by: willbot <[email protected]>
Signed-off-by: Will Madden <[email protected]>
…efineConfig

Co-Authored-By: Claude Fable 5.2 <[email protected]>
Signed-off-by: willbot <[email protected]>
Signed-off-by: Will Madden <[email protected]>
…s its record unpublished, and names itself

A Prisma schema source built for another target and given no capabilities now gets only the CONTRACT.TARGET_MISMATCH error: the config reads the record of sources given no capabilities before any wrapper spreads the source, and the target refusal stays inside the default.

Only isSourceGivenNoCapabilities is public. The record function moves to the unpublished subpath sources-given-no-capabilities, which prisma7Contract imports within the same published package.

Every part of the stopgap carries "Prisma 8.0 removes" in its doc comment, so one search finds them.

Co-Authored-By: Claude Fable 5.2 <[email protected]>
Signed-off-by: willbot <[email protected]>
Signed-off-by: Will Madden <[email protected]>
…ning's import goes in the file it names

The client refuses the features that need a capability, but includes still work with one query per relation. For a TypeScript contract the warning's import goes in the contract file, not the config.

Co-Authored-By: Claude Fable 5.2 <[email protected]>
Signed-off-by: willbot <[email protected]>
Signed-off-by: Will Madden <[email protected]>
…s tests, docs and an upgrade instruction

Co-Authored-By: Claude Fable 5.2 <[email protected]>
Signed-off-by: willbot <[email protected]>
Signed-off-by: Will Madden <[email protected]>
@github-actions

github-actions Bot commented Nov 27, 2026 •

Copy link
Copy Markdown
Contributor

Public API changes

This pull request changes the api.txt list of 16 packages and the recorded breaks or expected example-app errors of 18 packages or apps. Its description needs a section headed ## API changes that names each export below, in backticks, on a line that says why it changes. A package name in backticks, on a line with a reason, covers every change in that package. A change to a package’s api-breaks.json is named by the package, and a change to examples/last-release-errors.json by examples/<app>. You can start from this:

## API changes

- `@prisma/orm-better-auth (not exported): PrismaClientLike`:
- `@prisma/orm-better-auth (not exported): PrismaClientLikeFor`:
- `@prisma/orm-better-auth (not exported): TransactionalPrismaClientLike`:
- `@prisma/orm-better-auth: prismaAdapter`:
- `@prisma/orm-extension-paradedb`:
- `@prisma/orm-extension-paradedb (not exported): paradedbPackMetaBase`:
- `@prisma/orm-extension-paradedb/pack: default`:
- `@prisma/orm-extension-pgvector`:
- `@prisma/orm-extension-pgvector (not exported): pgvectorPackMetaBase`:
- `@prisma/orm-extension-postgis`:
- `@prisma/orm-extension-postgis (not exported): postgisPackMetaBase`:
- `@prisma/orm-extension-supabase`:
- `@prisma/orm-extension-supabase (not exported): ContractBase`:
- `@prisma/orm-extension-supabase (not exported): SupabaseStackProvides`:
- `@prisma/orm-extension-supabase/runtime: RoleBoundDb`:
- `@prisma/orm-extension-supabase/runtime: supabase`:
- `@prisma/orm-family-mongo`:
- `@prisma/orm-family-sql`:
- `@prisma/orm-family-sql`: (51 exports)
- `@prisma/orm-framework`:
- `@prisma/orm-framework/components/control: CapabilityFirstAvailable`:
- `@prisma/orm-framework/components/control: DatabaseCapabilitiesNotProvided`:
- `@prisma/orm-framework/components/control: DatabaseCapabilitiesNotProvidedExplanation`:
- `@prisma/orm-framework/components/control: DatabaseCapabilitiesNotProvidedFinding`:
- `@prisma/orm-framework/components/control: DatabaseVersion`:
- `@prisma/orm-framework/components/control: DiffableNode`:
- `@prisma/orm-framework/components/control: MigrationRunnerFailureMeta`:
- `@prisma/orm-framework/components/control: MismatchCause`:
- `@prisma/orm-framework/components/control: MismatchExplanation`:
- `@prisma/orm-framework/components/control: NodeMismatchExplanation`:
- `@prisma/orm-framework/components/control: databaseCapabilitiesNotProvidedIssue`:
- `@prisma/orm-framework/components/control: databaseCapabilitiesNotProvidedText`:
- `@prisma/orm-framework/components: CapabilityFirstAvailable`:
- `@prisma/orm-framework/components: DatabaseCapabilitiesNotProvided`:
- `@prisma/orm-framework/components: DatabaseCapabilitiesNotProvidedExplanation`:
- `@prisma/orm-framework/components: DatabaseCapabilitiesNotProvidedFinding`:
- `@prisma/orm-framework/components: DatabaseVersion`:
- `@prisma/orm-framework/components: DiffableNode`:
- `@prisma/orm-framework/components: MigrationRunnerFailureMeta`:
- `@prisma/orm-framework/components: MismatchCause`:
- `@prisma/orm-framework/components: MismatchExplanation`:
- `@prisma/orm-framework/components: NodeMismatchExplanation`:
- `@prisma/orm-framework/components: databaseCapabilitiesNotProvidedIssue`:
- `@prisma/orm-framework/components: databaseCapabilitiesNotProvidedText`:
- `@prisma/orm-mariadb`:
- `@prisma/orm-mariadb/family-contract/capability-messages: everything from @prisma/orm-family-sql/contract/capability-messages`:
- `@prisma/orm-mongo`:
- `@prisma/orm-mysql`:
- `@prisma/orm-mysql/family-contract/capability-messages: everything from @prisma/orm-family-sql/contract/capability-messages`:
- `@prisma/orm-postgres`:
- `@prisma/orm-postgres (not exported): DefaultRequiredCapabilities`:
- `@prisma/orm-postgres (not exported): PostgresAdapter`:
- `@prisma/orm-postgres (not exported): PostgresBaseScaffold`:
- `@prisma/orm-postgres (not exported): PostgresContributions`:
- `@prisma/orm-postgres (not exported): PostgresDefinition`:
- `@prisma/orm-postgres (not exported): PostgresResult`:
- `@prisma/orm-postgres (not exported): PostgresRuntimeBoundMembers`:
- `@prisma/orm-postgres (not exported): PostgresScaffold`:
- `@prisma/orm-postgres (not exported): PostgresStackProvides`:
- `@prisma/orm-postgres (not exported): defaultRequiredCapabilityLists`:
- `@prisma/orm-postgres (not exported): providedCapabilityLists`:
- `@prisma/orm-postgres/adapter/capabilities: everything from @prisma/orm-target-postgres/adapter/capabilities`:
- `@prisma/orm-postgres/config: PostgresConfigOptions`:
- `@prisma/orm-postgres/config: PostgresContractCapabilities`:
- `@prisma/orm-postgres/config: PostgresContractEntry`:
- `@prisma/orm-postgres/config: Prisma7SchemaOptions`:
- `@prisma/orm-postgres/config: RequiredCapabilities`:
- `@prisma/orm-postgres/config: defineConfig`:
- `@prisma/orm-postgres/config: postgres15`:
- `@prisma/orm-postgres/config: postgres16`:
- `@prisma/orm-postgres/config: postgres17`:
- `@prisma/orm-postgres/config: postgres18`:
- `@prisma/orm-postgres/config: postgresContractCapabilities`:
- `@prisma/orm-postgres/config: postgresDriver`:
- `@prisma/orm-postgres/config: prisma7Schema`:
- `@prisma/orm-postgres/contract-builder: PostgresContractCapabilities`:
- `@prisma/orm-postgres/contract-builder: RequiredCapabilities`:
- `@prisma/orm-postgres/contract-builder: defineContract`:
- `@prisma/orm-postgres/contract-builder: postgres15`:
- `@prisma/orm-postgres/contract-builder: postgres16`:
- `@prisma/orm-postgres/contract-builder: postgres17`:
- `@prisma/orm-postgres/contract-builder: postgres18`:
- `@prisma/orm-postgres/contract-builder: postgresDriver`:
- `@prisma/orm-postgres/driver/capabilities: everything from @prisma/orm-target-postgres/driver/capabilities`:
- `@prisma/orm-postgres/family-contract/capability-messages: everything from @prisma/orm-family-sql/contract/capability-messages`:
- `@prisma/orm-postgres/runtime: InteractiveTransactionsCapability`:
- `@prisma/orm-postgres/runtime: PostgresTransactionCallback`:
- `@prisma/orm-postgres/runtime: default`:
- `@prisma/orm-postgres/serverless: default`:
- `@prisma/orm-postgres/target/server-version-range: everything from @prisma/orm-target-postgres/target/server-version-range`:
- `@prisma/orm-sqlite`:
- `@prisma/orm-sqlite/family-contract/capability-messages: everything from @prisma/orm-family-sql/contract/capability-messages`:
- `@prisma/orm-target-mariadb`:
- `@prisma/orm-target-mariadb/adapter/adapter: mariadbAdapterCapabilities`:
- `@prisma/orm-target-mariadb/adapter/adapter: mariadbAdapterContractContributions`:
- `@prisma/orm-target-mariadb/adapter/adapter: mariadbAdapterDescriptorMeta`:
- `@prisma/orm-target-mariadb/adapter: mariadbAdapterCapabilities`:
- `@prisma/orm-target-mariadb/adapter: mariadbAdapterContractContributions`:
- `@prisma/orm-target-mariadb/adapter: mariadbAdapterDescriptorMeta`:
- `@prisma/orm-target-mongo`:
- `@prisma/orm-target-mysql`:
- `@prisma/orm-target-mysql/adapter/adapter: mysqlAdapterCapabilities`:
- `@prisma/orm-target-mysql/adapter/adapter: mysqlAdapterContractContributions`:
- `@prisma/orm-target-mysql/adapter/adapter: mysqlAdapterDescriptorMeta`:
- `@prisma/orm-target-mysql/adapter: mysqlAdapterCapabilities`:
- `@prisma/orm-target-mysql/adapter: mysqlAdapterContractContributions`:
- `@prisma/orm-target-mysql/adapter: mysqlAdapterDescriptorMeta`:
- `@prisma/orm-target-postgres`:
- `@prisma/orm-target-postgres (not exported): CapabilitiesByVersion`:
- `@prisma/orm-target-postgres (not exported): DatabaseCapabilitiesOf`:
- `@prisma/orm-target-postgres (not exported): FlagsOf`:
- `@prisma/orm-target-postgres (not exported): NamespacesOf`:
- `@prisma/orm-target-postgres (not exported): RowOf`:
- `@prisma/orm-target-postgres (not exported): postgresDatabaseCapabilities`:
- `@prisma/orm-target-postgres (not exported): postgresVersions`:
- `@prisma/orm-target-postgres/adapter/adapter: postgresAdapterCapabilities`:
- `@prisma/orm-target-postgres/adapter/adapter: postgresAdapterContractContributions`:
- `@prisma/orm-target-postgres/adapter/capabilities: postgresAdapterCapabilities`:
- `@prisma/orm-target-postgres/adapter/runtime: default`:
- `@prisma/orm-target-postgres/adapter/sql-renderer: renderLoweredSql`:
- `@prisma/orm-target-postgres/adapter: postgresAdapterCapabilities`:
- `@prisma/orm-target-postgres/adapter: postgresAdapterContractContributions`:
- `@prisma/orm-target-postgres/adapter: renderLoweredSql`:
- `@prisma/orm-target-postgres/driver/capabilities: postgresDriverCapabilities`:
- `@prisma/orm-target-postgres/driver/runtime: default`:
- `@prisma/orm-target-postgres/driver: postgresDriverCapabilities`:
- `@prisma/orm-target-postgres/target/runtime: default`:
- `@prisma/orm-target-postgres/target/server-version-range: POSTGRES_MIN_SERVER_VERSION`:
- `@prisma/orm-target-postgres/target/server-version-range: POSTGRES_NEWEST_VERSION`:
- `@prisma/orm-target-postgres/target/server-version-range: PostgresVersion`:
- `@prisma/orm-target-postgres/target/server-version: POSTGRES_MIN_SERVER_VERSION`:
- `@prisma/orm-target-postgres/target/server-version: postgresCapabilitiesByVersion`:
- `@prisma/orm-target-postgres/target/server-version: postgresRetiredCapabilities`:
- `@prisma/orm-target-postgres/target/server-version: readPostgresServerVersionNumber`:
- `@prisma/orm-target-postgres/target/types: PostgresDatabaseSchemaNode`:
- `@prisma/orm-target-postgres/target/types: PostgresDatabaseSchemaNodeInput`:
- `@prisma/orm-target-postgres/target/types: PostgresExtensionSchemaNode`:
- `@prisma/orm-target-postgres/target: POSTGRES_MIN_SERVER_VERSION`:
- `@prisma/orm-target-postgres/target: POSTGRES_NEWEST_VERSION`:
- `@prisma/orm-target-postgres/target: PostgresDatabaseSchemaNode`:
- `@prisma/orm-target-postgres/target: PostgresDatabaseSchemaNodeInput`:
- `@prisma/orm-target-postgres/target: PostgresExtensionSchemaNode`:
- `@prisma/orm-target-postgres/target: PostgresVersion`:
- `@prisma/orm-target-postgres/target: postgresCapabilitiesByVersion`:
- `@prisma/orm-target-postgres/target: postgresRetiredCapabilities`:
- `@prisma/orm-target-postgres/target: readPostgresServerVersionNumber`:
- `@prisma/orm-target-sqlite`:
- `@prisma/orm-target-sqlite/adapter/adapter: sqliteAdapterCapabilities`:
- `@prisma/orm-target-sqlite/adapter/adapter: sqliteAdapterContractContributions`:
- `@prisma/orm-target-sqlite/adapter: sqliteAdapterCapabilities`:
- `@prisma/orm-target-sqlite/adapter: sqliteAdapterContractContributions`:
- `@prisma/orm-toolchain`:
- `@prisma/orm-toolchain/cli/init-contribution: ConfigModuleExports`:
- `@prisma/orm-toolchain/cli/init-contribution: ContractEntryInput`:
- `@prisma/orm-toolchain/cli/init-contribution: ContractEntryNode`:
- `@prisma/orm-toolchain/cli/init-contribution: InitContribution`:

@prisma/orm-better-auth

+ (not exported) interface PrismaClientLike, readonly optional property stack?: { readonly target: Pick<SqlRuntimeTargetDescriptor, 'retiredCapabilities'>; }
- (not exported) interface PrismaClientLike, required method transaction<R>(fn: (tx: { readonly orm: object; }) => PromiseLike<R>): Promise<R>
+ (not exported) interface TransactionalPrismaClientLike extends PrismaClientLike
+ (not exported) interface TransactionalPrismaClientLike, required method transaction<R>(fn: (tx: { readonly orm: object; }) => PromiseLike<R>): Promise<R>
+ (not exported) type PrismaClientLikeFor<Options extends PrismaAdapterOptions> = 'transaction' extends keyof Options ? true extends Options['transaction' & keyof Options] ? TransactionalPrismaClientLike : PrismaClientLike : PrismaClientLike
- .: function prismaAdapter(db: PrismaClientLike, adapterOptions?: PrismaAdapterOptions): (betterAuthOptions: BetterAuthOptions) => DBAdapter<BetterAuthOptions>
+ .: function prismaAdapter<const Options extends PrismaAdapterOptions = Record<never, never>>(db: PrismaClientLikeFor<Options>, adapterOptions?: Options): (betterAuthOptions: BetterAuthOptions) => DBAdapter<BetterAuthOptions>

packages/9-public/@prisma/orm-extension-paradedb/api-breaks.json

+ {"path":"./control","export":"paradedbPackMeta","test":"value","kind":"break","lastRelease":"8.0.0-rc.25","fingerprint":"19b1ec42a4182491","reason":"An extension pack declares no capabilities, because a contract lists the capabilities it requires (prisma/orm#31218)."}
+ {"path":"./pack","export":"default","test":"value","kind":"break","lastRelease":"8.0.0-rc.25","fingerprint":"3d28f7b6d93e8b54","reason":"An extension pack declares no capabilities, because a contract lists the capabilities it requires (prisma/orm#31218)."}

@prisma/orm-extension-paradedb

- (not exported) const paradedbPackMetaBase: { readonly kind: "extension"; readonly id: "paradedb"; readonly familyId: "sql"; readonly targetId: "postgres"; readonly version: "0.0.1"; readonly capabilities: { readonly postgres: { readonly 'paradedb/bm25': true; }; }; readonly indexTypes: IndexTypeBuilder<Record<never, never> & Record<"bm25", { readonly options: { key_field: string; }; }>>; readonly types: { readonly queryOperationTypes: { readonly import: { readonly package: `${string}/operation-types`; readonly named: "QueryOperationTypes"; readonly alias: "ParadeDbQueryOperationTypes"; }; }; }; }
+ (not exported) const paradedbPackMetaBase: { readonly kind: "extension"; readonly id: "paradedb"; readonly familyId: "sql"; readonly targetId: "postgres"; readonly version: "0.0.1"; readonly indexTypes: IndexTypeBuilder<Record<never, never> & Record<"bm25", { readonly options: { key_field: string; }; }>>; readonly types: { readonly queryOperationTypes: { readonly import: { readonly package: `${string}/operation-types`; readonly named: "QueryOperationTypes"; readonly alias: "ParadeDbQueryOperationTypes"; }; }; }; }
- ./pack: export default = const paradedbPack: { readonly kind: "extension"; readonly id: "paradedb"; readonly familyId: "sql"; readonly targetId: "postgres"; readonly version: "0.0.1"; readonly capabilities: { readonly postgres: { readonly 'paradedb/bm25': true; }; }; readonly indexTypes: IndexTypeBuilder<Record<never, never> & Record<"bm25", { readonly options: { key_field: string; }; }>>; readonly types: { readonly queryOperationTypes: { readonly import: { readonly package: `${string}/operation-types`; readonly named: "QueryOperationTypes"; readonly alias: "ParadeDbQueryOperationTypes"; }; }; }; } & { readonly __queryOperationTypes?: QueryOperationTypesForCodecs; }
+ ./pack: export default = const paradedbPack: { readonly kind: "extension"; readonly id: "paradedb"; readonly familyId: "sql"; readonly targetId: "postgres"; readonly version: "0.0.1"; readonly indexTypes: IndexTypeBuilder<Record<never, never> & Record<"bm25", { readonly options: { key_field: string; }; }>>; readonly types: { readonly queryOperationTypes: { readonly import: { readonly package: `${string}/operation-types`; readonly named: "QueryOperationTypes"; readonly alias: "ParadeDbQueryOperationTypes"; }; }; }; } & { readonly __queryOperationTypes?: QueryOperationTypesForCodecs; }

packages/9-public/@prisma/orm-extension-pgvector/api-breaks.json

+ {"path":"./pack","export":"default","test":"value","kind":"break","lastRelease":"8.0.0-rc.25","fingerprint":"47778b77724a114d","reason":"An extension pack declares no capabilities, because a contract lists the capabilities it requires (prisma/orm#31218)."}

@prisma/orm-extension-pgvector

+ (not exported) const pgvectorPackMetaBase: { readonly kind: "extension"; readonly id: "pgvector"; readonly familyId: "sql"; readonly targetId: "postgres"; readonly version: "0.0.1"; readonly authoring: { readonly type: { readonly pgvector: { readonly Vector: { readonly kind: "typeConstructor"; readonly inferred: true; readonly args: readonly [{ readonly kind: "value"; readonly dataType: "pg/int4"; readonly name: "length"; readonly optional: true; }]; readonly output: { readonly codecId: "pg/vector@1"; readonly typeParams: { readonly length: { readonly kind: "arg"; readonly index: 0; }; }; }; }; }; }; }; readonly dataTypes: readonly DataType[]; readonly types: { readonly codecTypes: { readonly codecDescriptors: CodecDescriptor<unknown>[]; readonly import: { readonly package: `${string}/codec-types`; readonly named: "CodecTypes"; readonly alias: "PgVectorTypes"; }; readonly parameterizedOutputTypes: { readonly package: `${string}/codec-types`; readonly named: "ParameterizedOutputTypesForTypeParams"; readonly alias: "PgVectorParameterizedOutputTypes"; }; }; readonly operationTypes: { readonly import: { readonly package: `${string}/operation-types`; readonly named: "OperationTypes"; readonly alias: "PgVectorOperationTypes"; }; }; readonly queryOperationTypes: { readonly import: { readonly package: `${string}/operation-types`; readonly named: "QueryOperationTypes"; readonly alias: "PgVectorQueryOperationTypes"; }; }; }; }
- (not exported) const pgvectorPackMetaBase: { readonly kind: "extension"; readonly id: "pgvector"; readonly familyId: "sql"; readonly targetId: "postgres"; readonly version: "0.0.1"; readonly capabilities: { readonly postgres: { readonly 'pgvector.cosine': true; }; }; readonly authoring: { readonly type: { readonly pgvector: { readonly Vector: { readonly kind: "typeConstructor"; readonly inferred: true; readonly args: readonly [{ readonly kind: "value"; readonly dataType: "pg/int4"; readonly name: "length"; readonly optional: true; }]; readonly output: { readonly codecId: "pg/vector@1"; readonly typeParams: { readonly length: { readonly kind: "arg"; readonly index: 0; }; }; }; }; }; }; }; readonly dataTypes: readonly DataType[]; readonly types: { readonly codecTypes: { readonly codecDescriptors: CodecDescriptor<unknown>[]; readonly import: { readonly package: `${string}/codec-types`; readonly named: "CodecTypes"; readonly alias: "PgVectorTypes"; }; readonly parameterizedOutputTypes: { readonly package: `${string}/codec-types`; readonly named: "ParameterizedOutputTypesForTypeParams"; readonly alias: "PgVectorParameterizedOutputTypes"; }; }; readonly operationTypes: { readonly import: { readonly package: `${string}/operation-types`; readonly named: "OperationTypes"; readonly alias: "PgVectorOperationTypes"; }; }; readonly queryOperationTypes: { readonly import: { readonly package: `${string}/operation-types`; readonly named: "QueryOperationTypes"; readonly alias: "PgVectorQueryOperationTypes"; }; }; }; }

packages/9-public/@prisma/orm-extension-postgis/api-breaks.json

+ {"path":"./pack","export":"default","test":"value","kind":"break","lastRelease":"8.0.0-rc.25","fingerprint":"e8cfd4b27ee9d063","reason":"An extension pack declares no capabilities, because a contract lists the capabilities it requires (prisma/orm#31218)."}

@prisma/orm-extension-postgis

+ (not exported) const postgisPackMetaBase: { readonly kind: "extension"; readonly id: "postgis"; readonly familyId: "sql"; readonly targetId: "postgres"; readonly version: "0.0.1"; readonly authoring: { readonly type: { readonly postgis: { readonly Geometry: { readonly kind: "typeConstructor"; readonly inferred: true; readonly args: readonly [{ readonly kind: "value"; readonly dataType: "pg/int4"; readonly name: "srid"; readonly optional: true; }]; readonly output: { readonly codecId: "pg/geometry@1"; readonly typeParams: { readonly srid: { readonly kind: "arg"; readonly index: 0; }; }; }; }; }; }; }; readonly dataTypes: readonly DataType[]; readonly types: { readonly codecTypes: { readonly codecDescriptors: CodecDescriptor<unknown>[]; readonly import: { readonly package: `${string}/codec-types`; readonly named: "CodecTypes"; readonly alias: "PostgisTypes"; }; }; readonly queryOperationTypes: { readonly import: { readonly package: `${string}/operation-types`; readonly named: "QueryOperationTypes"; readonly alias: "PostgisQueryOperationTypes"; }; }; }; }
- (not exported) const postgisPackMetaBase: { readonly kind: "extension"; readonly id: "postgis"; readonly familyId: "sql"; readonly targetId: "postgres"; readonly version: "0.0.1"; readonly capabilities: { readonly postgres: { readonly 'postgis.geometry': true; }; }; readonly authoring: { readonly type: { readonly postgis: { readonly Geometry: { readonly kind: "typeConstructor"; readonly inferred: true; readonly args: readonly [{ readonly kind: "value"; readonly dataType: "pg/int4"; readonly name: "srid"; readonly optional: true; }]; readonly output: { readonly codecId: "pg/geometry@1"; readonly typeParams: { readonly srid: { readonly kind: "arg"; readonly index: 0; }; }; }; }; }; }; }; readonly dataTypes: readonly DataType[]; readonly types: { readonly codecTypes: { readonly codecDescriptors: CodecDescriptor<unknown>[]; readonly import: { readonly package: `${string}/codec-types`; readonly named: "CodecTypes"; readonly alias: "PostgisTypes"; }; }; readonly queryOperationTypes: { readonly import: { readonly package: `${string}/operation-types`; readonly named: "QueryOperationTypes"; readonly alias: "PostgisQueryOperationTypes"; }; }; }; }

packages/9-public/@prisma/orm-extension-supabase/api-breaks.json

- {"path":"./runtime","export":"RoleBoundDb","test":"type","kind":"break","lastRelease":"8.0.0-rc.25","fingerprint":"34261bf6461da021","reason":"A column name that several joined tables share must now name its table (prisma/orm#31150)."}
+ {"path":"./runtime","export":"RoleBoundDb","test":"type","kind":"break","lastRelease":"8.0.0-rc.25","fingerprint":"4fb4ddf7775003e4","reason":"A column name that several joined tables share must now name its table (prisma/orm#31150), and `transaction()` is a type error for a contract that does not require `sql.interactiveTransactions`; a release candidate's contract may still call it (prisma/orm#31218)."}
+ {"path":"./runtime","export":"ServiceRoleDb","test":"type","kind":"break","lastRelease":"8.0.0-rc.25","fingerprint":"3c9d16b4eda4510c","reason":"A column name that several joined tables share must now name its table (prisma/orm#31150), and `transaction()` is a type error for a contract that does not require `sql.interactiveTransactions`; a release candidate's contract may still call it (prisma/orm#31218)."}
- {"path":"./runtime","export":"ServiceRoleDb","test":"type","kind":"break","lastRelease":"8.0.0-rc.25","fingerprint":"61772b2813420f86","reason":"A column name that several joined tables share must now name its table (prisma/orm#31150)."}
+ {"path":"./runtime","export":"SupabaseDb","test":"type","kind":"break","lastRelease":"8.0.0-rc.25","fingerprint":"d355ac44c3abb036","reason":"A column name that several joined tables share must now name its table (prisma/orm#31150), and `transaction()` is a type error for a contract that does not require `sql.interactiveTransactions`; a release candidate's contract may still call it (prisma/orm#31218)."}
+ {"path":"./runtime","export":"SupabaseExtensionContract","test":"type","kind":"break","lastRelease":"8.0.0-rc.25","fingerprint":"aa1d211f375e6a3c","reason":"The Supabase contract's capabilities are the ones it requires; the `postgres` flags this release retired, such as `jsonAgg`, are gone (prisma/orm#31218)."}
+ {"path":"./runtime","export":"SupabaseInternalDb","test":"type","kind":"break","lastRelease":"8.0.0-rc.25","fingerprint":"927d50a8cf68b4ae","reason":"The Supabase contract's capabilities are the ones it requires; the `postgres` flags this release retired, such as `jsonAgg`, are gone (prisma/orm#31218)."}

631 lines are left out here. The full list is in the job summary of the "API changes" check.

@wmadden-electric wmadden-electric changed the title feat(postgres)!: a PostgreSQL contract must list the capabilities it requires feat(postgres)!: a PostgreSQL contract lists the capabilities it requires (optional, with a warning, until 8.0) Nov 27, 2026
wmadden-electric and others added 5 commits November 27, 2026 20:41
Co-Authored-By: Claude Fable 5.2 <[email protected]>
Signed-off-by: willbot <[email protected]>
Signed-off-by: Will Madden <[email protected]>
… compiling

POSTGRES_MIN_SERVER_VERSION is exported from the target's server-version path again, postgresAdapterCapabilities from the adapter's adapter path again, and verifySqlSchemaByDiff's databaseCapabilitiesNotProvided input is optional, as its reader already treats it.

Co-Authored-By: Claude Fable 5.2 <[email protected]>
Signed-off-by: willbot <[email protected]>
Signed-off-by: Will Madden <[email protected]>
…nst release candidate 25

Co-Authored-By: Claude Fable 5.2 <[email protected]>
Signed-off-by: willbot <[email protected]>
Signed-off-by: Will Madden <[email protected]>
…meter

Co-Authored-By: Claude Fable 5.2 <[email protected]>
Signed-off-by: willbot <[email protected]>
Signed-off-by: Will Madden <[email protected]>
…onContext keep compiling

renderLoweredSql takes its old fifth argument again, and
createExecutionContext its old driver option, both ignored until
Prisma 8.0 removes them. The API check cannot see either break: a
function with fewer parameters, or an options object with fewer
properties, is assignable to the old type. A type test for each shows
the old call compiles.

The restored import paths of POSTGRES_MIN_SERVER_VERSION and
postgresAdapterCapabilities are marked as part of the stopgap. The
upgrade instructions say the old forms keep working until 8.0, and
their detection matches the names, not an import path every project
using createPostgresAdapter has.

Co-Authored-By: Claude Fable 5.2 <[email protected]>
Signed-off-by: willbot <[email protected]>
Signed-off-by: Will Madden <[email protected]>
@wmadden-electric
wmadden-electric marked this pull request as ready for review November 27, 2026 10:36
@wmadden-electric
wmadden-electric added this pull request to the merge queue Nov 27, 2026
@github-merge-queue
github-merge-queue Bot removed this pull request from the merge queue due to failed status checks Nov 27, 2026
wmadden-electric and others added 2 commits November 27, 2026 22:34
…abilities

- A contract that leaves out sql.insertOnConflictTarget now refuses upserts and
  skips on named columns, since the runtime no longer adds the adapter's
  capabilities; the test asserts the refusals and the untargeted skip.
- The PSL round-trip walker expects the two release candidate 25 contracts to
  be refused for the same missing foreign key as the current emits of the same
  domain and storage.
- The pgvector declaration test no longer rewrites the fixture's import line,
  whose formatting changed, so emit found `extension` undefined; it adds its
  own import and fails loudly if the fixture's opening line moves.

Co-Authored-By: Claude Fable 5.2 <[email protected]>
Signed-off-by: willbot <[email protected]>
Signed-off-by: Will Madden <[email protected]>
…ves the capability out

Co-Authored-By: Claude Fable 5.2 <[email protected]>
Signed-off-by: willbot <[email protected]>
Signed-off-by: Will Madden <[email protected]>
@wmadden-electric
wmadden-electric added this pull request to the merge queue Nov 27, 2026
@github-merge-queue
github-merge-queue Bot removed this pull request from the merge queue due to a conflict with the base branch Nov 27, 2026
Co-Authored-By: Claude Fable 5.2 <[email protected]>
Signed-off-by: willbot <[email protected]>
Signed-off-by: Will Madden <[email protected]>
@wmadden-electric
wmadden-electric added this pull request to the merge queue Nov 27, 2026
Merged via the queue into main with commit 134a5f5 Nov 27, 2026
27 checks passed
@wmadden-electric
wmadden-electric deleted the tml-3960-capabilities-by-database-version branch November 27, 2026 12:44
opensource-fork-sync Bot pushed a commit to cla7aye15I4nd/opensource-prisma__orm that referenced this pull request Nov 29, 2026
…e extension reuses as Early Access, not GA (prisma#31241)

## At a glance

From release 8.0, everything a user can import from a generally
available (GA) package must keep working until Prisma 9. This pull
request decides that the building blocks of the PostgreSQL client are
**not** promised that long. They are published under Early Access names,
which may change in any release, and the `internal` import paths that
held them are deleted.

The Supabase extension is the one caller. Before:

```ts
import { connectWithBinding, validateTransactionOptions } from '@prisma/orm-postgres/internal/options'
import { buildPostgresStaticContext } from '@prisma/orm-postgres/internal/static-context'
import { buildPostgresQueryMembers } from '@prisma/orm-postgres/internal/transaction-members'
import { validatePostgresContract } from '@prisma/orm-postgres/internal/validate-contract'
import { PostgresRuntimeImpl } from '@prisma/orm-postgres/runtime'
import { preparedStatementQuery } from '@prisma/orm-family-sql/runtime/internal/prepared-query'
```

After:

```ts
import { ea_connectWithBinding, ea_validateTransactionOptions, ea_buildPostgresQueryMembers, Ea_PostgresRuntimeImpl } from '@prisma/orm-postgres/runtime'
import { ea_buildPostgresStaticContext, ea_validatePostgresContract } from '@prisma/orm-postgres/static'
import { ea_preparedStatementQuery } from '@prisma/orm-family-sql/runtime'
```

The code behind each name is unchanged. What breaks is any code that
imports the deleted `internal` paths or the old class name
`PostgresRuntimeImpl`. That is extension code only: no example
application, user guide or `prisma orm init` template imports them.

## Background

`@prisma/orm-postgres` is the PostgreSQL *facade*: the one package an
application installs to use PostgreSQL. Its `runtime` path exports
`postgres()`, which builds the client an application queries with.

`@prisma/orm-extension-supabase` is a separate published package. Its
`supabase()` builds a different PostgreSQL client: one with no query
interface until the application binds a database role, so no query can
run without a role. It assembles that client from the same pieces as
`postgres()`: connection handling, the builder for the client's `sql`,
`orm` and `transaction` members, the option checks, and the runtime
class, which it subclasses. Because it is a separate package, it can
only use what the facade publishes, and the facade published those
pieces on four import paths named `internal`, for Supabase alone.

Anyone could import those paths, and nothing told a reader they might
change.

## The decision

The `ea_` prefix (`Ea_` for a type or class) marks a name as Early
Access. `docs/oss/versioning.md` defines it: an Early Access name may
change in any release, and the CI check that compares each package's
exports with the last release does not fail when one changes.

These pieces get that prefix because they are the seams inside
`postgres()`. They were cut out of it so Supabase could reuse them, not
designed as an interface. Their signatures expose how the client is put
together today: `buildPostgresQueryMembers` takes the execution context,
the query builder and a transaction context as separate inputs.
Publishing them under plain names would freeze that structure until
Prisma 9. If they prove stable, a later release adds plain names beside
the prefixed ones.

One limit: the prepared-query names also key members of the SQL family's
`SqlRuntimeBase`, a GA class. The CI check judges a class's members as
part of it, so changing those names would still be a recorded break.
Settling that class's own level is the project's next platform slice;
the plan records it.

They move onto the paths that already load their code: `runtime`, where
`postgres()` lives, and `static`, which holds the parts that need no
database driver.

## What changes

- **`@prisma/orm-postgres`** deletes `internal/options`,
`internal/static-context`, `internal/transaction-members` and
`internal/validate-contract`. Their exports move to `runtime` and
`static` with the prefix, and `PostgresRuntimeImpl` becomes
`Ea_PostgresRuntimeImpl`.
- **`@prisma/orm-family-sql`**, the package shared by every SQL
database, deletes `runtime/internal/prepared-query`. The seven names
Supabase uses move to `runtime` with the prefix. The path's six other
names (`settlementOf`, `transactionSettlement`, `wasRefusedBeforeBegin`
and three types) are no longer exported at all: nothing outside the
package uses them, and every name we export is one we must keep in some
form.
- **`@prisma/orm-mysql`, `@prisma/orm-mariadb` and
`@prisma/orm-sqlite`** each re-export the SQL family's paths under their
own name, so each loses `family-runtime/internal/prepared-query` too.
- **The Supabase extension** imports the new names. It already lists
`@prisma/orm-postgres` as a peer dependency; the decision record on the
published packages now says it is the only extension that builds on a
facade instead of the lower-level packages.
- **Upgrade instructions** for extension authors list each old import
and its replacement.

## A change from the design we agreed

The design moved the runtime class and `validatePostgresContract` into
`@prisma/orm-target-postgres`, the lower-level PostgreSQL package.
Building it showed that was wrong, so both stay in the facade:

- The target package deliberately does not depend on the SQL runtime
package. Migrations and the `prisma orm` commands load the target, and
keeping the query-execution code out of that load is the reason.
`PostgresRuntimeImpl` extends a class from the SQL runtime, so moving it
would pull that code in.
- `validatePostgresContract` and `contractFromJson` mark a contract as
validated under one shared key, so a contract checked by one is not
checked again by the other. Moving one of them to another package would
need that key exported and kept in step across packages.

Either way the names are published at Early Access, so users are
promised the same thing.

## API changes

The CI check requires each package whose export list changed to be named
here.

- `@prisma/orm-postgres`: the five removed paths, and
`PostgresRuntimeImpl` renamed `Ea_PostgresRuntimeImpl`. `runtime` adds
`ea_resolveOptionalPostgresBinding`, `ea_connectWithBinding`,
`Ea_PostgresBindingRules`, `ea_buildPostgresQueryMembers`,
`ea_validateTransactionOptions`, `ea_validateCursorOptions` and
`ea_toDriverCursorOptions`; `static` adds
`ea_buildPostgresStaticContext` and `ea_validatePostgresContract`. Each
is a part of `postgres()` the Supabase extension reuses. Five earlier
break records (prisma#31150, prisma#31218) were updated: a
record is tied to the exact text of the types it covers, and these
covered the copies of `PostgresStaticContext` under the deleted
`internal/static-context` path. With those copies gone, the check could
also compare `serverless` and `static`'s default exports, which it had
left undecided, and found the same column-name break (prisma#31150)
in them; two records were added for it.
- `@prisma/orm-family-sql`: `runtime/internal/prepared-query` removed;
`runtime` adds the seven `ea_`/`Ea_` names above.
- `@prisma/orm-mysql`: `family-runtime/internal/prepared-query` removed,
because the SQL family's path it re-exported is removed.
- `@prisma/orm-mariadb`: `family-runtime/internal/prepared-query`
removed, because the SQL family's path it re-exported is removed.
- `@prisma/orm-sqlite`: `family-runtime/internal/prepared-query`
removed, because the SQL family's path it re-exported is removed.
- `@prisma/orm-extension-supabase`: no change to its own exports; three
records updated because `RoleBoundDb`, which the three types build on,
now extends `Ea_PreparedStatementQueryTarget` and
`Ea_PreparedStatementExecuteTarget`.

## How it was checked

- The export comparison against the last release passes for each of the
six packages, with every break recorded.
- Type check and lint pass for the facade, the SQL runtime, the Supabase
extension and the integration tests, which use the runtime class; the
layering check passes.
- The Supabase extension's 267 tests pass. They run its client, which
calls every renamed piece. A new facade test checks that the prefixed
names are on `runtime` and `static` and the old names are gone.
- `postgres()` itself is unchanged: the facade exports its existing
functions under a second name (`export { buildPostgresQueryMembers as
ea_buildPostgresQueryMembers }`) and its own code still calls them
directly.

## Alternatives considered

- **Keep the `internal` paths and document them as unstable.** Rejected:
a reader cannot see a document from an import line, and the CI check
treats every path of a GA package as promised. A name prefix is visible
wherever the name is used.
- **A separate import path for extension authors**, such as
`@prisma/orm-postgres/runtime-toolkit`. Rejected: `runtime` already
loads this code, so a separate path keeps nothing out of an
application's bundle. The level belongs in the name, which the reader
sees at every use.
- **Publish them as GA under plain names.** Rejected: it freezes the
structure of `postgres()` until Prisma 9, for one caller we expect to
change.
- **A role-binding hook on `postgres()`, with Supabase as a thin layer
on top.** Rejected: Supabase's client must have no query interface until
a role is bound. A hook can add to `postgres()`'s client but cannot
remove the interface it already has.

Part of the project to reduce what the GA packages export (Linear
TML-3979). Its plan is in `projects/reduce-exported-apis/`.

Agent: gilderoy-93

🤖 Generated with [Claude Code](https://claude.com/claude-code)


<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->

<!-- coderabbit-ai-generated:v1 -->

## Summary by CodeRabbit

* **Breaking Changes**
* Internal PostgreSQL and SQL runtime import paths are no longer
available. Extensions using them must update imports to the supported
runtime or static entry points; some former exports have no replacement.
* PostgreSQL runtime and reusable helper APIs now use Early Access
names.
* **Documentation**
* Added upgrade guidance to help extension authors identify and update
affected imports.

<!-- end of auto-generated comment: release notes by coderabbit.ai -->

---------

Signed-off-by: willbot <[email protected]>
Signed-off-by: Will Madden <[email protected]>
Co-authored-by: Claude Fable 5.2 <[email protected]>
opensource-fork-sync Bot pushed a commit to cla7aye15I4nd/opensource-prisma__orm that referenced this pull request Nov 29, 2026
… stored enum value changes (prisma#31192)

## At a glance

A MongoDB user keeps `model User` and changes only what it is stored as:

```prisma
// before                          // after
model User {                       model User {
  id     String @id @Map("_id")      id     String @id @Map("_id")
  email  String                      email  String @Map("mail")
  status Status                      status Status
  @@Map("users")                     @@Map("app_users")
}                                  }

enum Status {                      enum Status {
  ACTIVE                             ACTIVE
  ARCHIVED @Map("archived")          ARCHIVED @Map("retired")
}                                  }
```

On `main`, `prisma migration plan` and `prisma db update` plan a drop of
collection `users` and a create of `app_users`. They then stop at the
consent prompt, which asks the user to allow the data loss with
`--delete User`. The `--rename` flag cannot help, because the model's
name did not change. The only way to keep the documents is to rename the
collection by hand.

With this pull request, both commands plan the following and ask
nothing. Each operation is labelled `widening`, which means it loses no
data:

```text
Rename collection users to app_users                                             widening
Rename field email to mail in collection app_users                               widening
Replace value "archived" with "retired" in field status of collection app_users  widening
```

The documents, indexes and validator move with the collection.
PostgreSQL and SQLite have worked this way since prisma#31088. Some
changes that MongoDB cannot apply safely are now refused instead, with
an error that explains how to make the change in two steps.

## The decision

1. **Stored-name changes are planned as renames and value
replacements.** [ADR
324](docs/architecture%20docs/adrs/ADR%20324%20-%20The%20same%20coordinate%20is%20the%20same%20object.md)
says that a model, field or enum member with the same name in the
database's current contract and in the new one is the same object, so
only its storage changes. ADR 324 was implemented for PostgreSQL and
SQLite and left MongoDB open. This pull request implements it for
MongoDB, as close to the SQL behaviour as MongoDB allows.
2. **Plans that would not survive a re-run are refused**, and the error
explains how to make the change in two migrations. The runner applies a
MongoDB migration one operation at a time, not in a transaction, because
collection commands such as `renameCollection` cannot run inside one. A
migration that stops part way is finished by running it again: each
operation checks the database before and after it runs, and a re-run
skips one whose after-check already holds. So every plan must give the
right result when run again after a stop.
3. **`--rename` of a model that shares its collection with another model
is refused**, and the error prints a hand-written move of that model's
documents. Renaming the collection would move every document in it, and
nothing in a document says which model it belongs to.

### What changes for existing users

- The changes in decision 1 are planned instead of asked about.
- On `main`, `--rename` of a model that shares its collection renamed
the whole collection, so the other model's documents moved too. It is
now refused (decision 3).
- On `main`, renaming a field of `Member` in the same change in which
`Guest`, which stores the same field, joins `Member`'s collection was
planned. It is now refused (the last item of section 2).

## 1. What is planned

A variant is a model stored in its base model's collection; a
discriminator field in each document says which variant it is.

- **`@@map` change:** `renameCollection`.
- **`@map` change on a field:** a field rename (`$rename`). On a
variant, it touches only that variant's documents.
- **`@map` change on a field of an embedded model:** the key is renamed
in every place that embedded model is stored.
- **A changed stored value of an enum member:** the value is replaced in
every field and nested key of that enum type, in single values and in
lists.
- **Combined with other changes:** type changes, `--rename` and
`--delete` act on the collection under its new name. The consent prompt
still names the model and field as the user wrote them.
- **`db update` on a database where the collection was already renamed
by hand:** no collection operation is planned, and the rest of the plan
acts on the collection under its new name.

`createCollection` now has an after-check, which re-runs need. On `main`
it had none, so a migration that created a collection could not be run
again after a later step stopped: the re-run tried the create again, and
its before-check failed. The after-check holds only when the collection
exists with every option the call sets, its whole validator included, so
a collection made another way still stops the create. Migrations users
already emitted keep the old create until their `ops.json` is written
again; the upgrade note says what to do after a stop with one of those.
When such a create finds its collection already there, the runner's
error says it cannot tell whether an earlier run made it, and gives its
routes: write `ops.json` again if no other database applied the
migration; drop the collection only if it holds nothing you need, even
when an earlier run of the command created it, and then run the command
that stopped again as it was run; or, on every database, move the
collection aside and copy it back. The message names that route and
points to the section "Moving a MongoDB collection aside" in the error
reference, which gives the steps: stop writes until every step is done,
move aside the collection the error names, removing a kept regular
collection's validator with `collMod` before editing its documents (a
time-series collection is copied with `$out` into a time-series
collection with the same options, since MongoDB cannot rename one and
its `_id` need not be unique), run `db migrate --to` the migration, make
the documents meet the validator and unique indexes, list and compare
the documents the run wrote again under the same `_id` (deleting a
time-series document with a filter that matches it alone, since its
`_id` need not be unique), copy them back, and drop the moved copy only
once each of its documents is in the collection or deliberately not
kept, and finally run the command that stopped again exactly as it was
run. The message says the next run may stop at another create in the
same state, where the same steps apply, and that an earlier run may have
moved documents into the collection from a collection it then emptied.
An extension migration gets no "write `ops.json` again" route, since its
operations come from the extension's package. Where the change policy
permits `reconcile`, it also offers applying the remaining operations by
hand and then `db sign` with the migration's directory name (`db sign`
checks collections, validators and indexes, not documents, and
afterwards `migration status` shows the database up to date without
marking that migration as applied). Every contract space's runner
receives the database's policies through one option, `policiesInForce`,
so an extension space gets the same advice; the runner itself uses them
to guard only the application space's marker. The repository's own
`examples/retail-store` initial migration is written again, and its
migration hash changes.

## 2. What is refused, and why

Each refusal is `MIGRATION.PLANNING_FAILED`. Its text explains how to
make the change in two migrations: first give the objects temporary
names that neither contract uses (the error suggests them, and says to
pick others if the database already has one), plan and apply that, then
give them their final names and plan again.

These refusals apply to collection names, field stored names, embedded
keys and enum stored values.

Refused as on SQL, because the plan would read one model's documents as
another's:

- **Swaps:** `User` moves from `users` to `accounts` while `Account`
moves from `accounts` to `users`. The error reads `Cannot rename
collection "accounts" to "users": collection "users" is renamed in the
same plan`.
- **Takeovers:** field `email` is removed, and field `contact` takes its
stored name `email`.
- **An enum mapped to `true`/`false` whose two values swap.** The error
says to keep the stored values in the contract. It gives no
two-migration route, because a boolean field has no third value to hold
one side while the other moves.
- **`db update` when the database has both the old and the new
collection.** The error names the fix for each cause:
  - the rename was half done by hand;
  - something wrote to the new collection first;
  - the old collection was renamed by hand and its name then reused.

Refused on MongoDB only, because a re-run after a stop would go wrong:

- **Chains:** `users` is renamed to `accounts` while `accounts` is
renamed to `archive`. Ordered `accounts` first, the first run is right,
but a re-run after a stop finds documents under `accounts` again and
moves them on to `archive`. The same holds for enum stored values that
shift along a chain, which SQL plans in one transaction.
- **A plan that frees a collection name and creates a new collection
under it.** Example: `users` is renamed to `app_users`, and a new model
creates `users`. If the plan stops after the create, a re-run finds both
collections, and the rename's before-check fails on every run.
- **A rewrite of one model's field that would also reach documents of a
model joining the same collection.** Example: `Member` renames its field
`name`, and `Guest`, which also stores `name`, joins collection
`members` in the same change. The rename would also rename the field in
`Guest`'s documents. This holds even when `Guest` is new: a hand-written
step in the same migration may copy its documents in, so the planner
cannot assume it has none. The error says what works: make the rename in
an earlier migration, before `Guest` joins the collection. ADR 324
records the rule.

## 3. Moving a model out of a shared collection

Two models that are not variants can share one collection:

```prisma
// before                        // after
model User {                     model Member {
  name String                      fullName String
  @@Map("people")                  @@Map("members")
}                                }
model Admin {                    model Admin {
  level Int                        level Int
  @@Map("people")                  @@Map("people")
}                                }
```

On `main`, `--rename User:Member --rename Member.name:Member.fullName`
renames collection `people` to `members`, so `Admin`'s documents move
with it and `Admin` reads an empty collection. That `--rename` is now
refused. The error says what the plan without it does: `User`'s
documents stay in `people`, and `Admin` keeps reading them. To move
them, the error prints steps for the `migration.ts` of that plan:

```ts
dataTransform({
  run: () => rawAggregate("people", [
    { $match: <a filter that selects only User's documents> },
    { $set: { fullName: "$name" } },
    { $unset: ["name"] },
    { $merge: { into: "members" } },
  ], { bypassDocumentValidation: true }),
}),
deleteDocuments({ collection: "people", filter: <the same filter> }),
```

The user writes the filter, because only they know which documents are
`User`'s. The error works out everything else by planning the change
again, in full, without the refused `--rename` flags, so it describes
the plan the user will get:

- **Where the steps go:** right after the plan creates the target
collection, right after it renames another collection to the target's
name, or at the start of the migration if the target collection already
exists.
- **The stages:** they write the model's renamed fields and its
discriminator value if it becomes a variant, and they drop the fields it
no longer stores. The text names the fields whose values are dropped.
- **`bypassDocumentValidation`:** added only when a later operation in
the plan replaces the target's validator and checks every document, the
copied ones included. `rawAggregate` now takes this option, as
`rawUpdateMany` already did. [ADR
188](docs/architecture%20docs/adrs/ADR%20188%20-%20MongoDB%20migration%20operation%20model.md)
records why the copy must run under the target's old validator.
- **Several models:** one set of steps covers every model the refused
flags would move. When the plan without the flags drops the source
collection, the steps move every model leaving it.
- **A time-series target:** `$merge` cannot write into a time-series
collection, so the copy reads the target, adds the moved documents with
`$unionWith`, and writes the result back with `$out`. A lone `$out` copy
was rejected: run again after its delete, it finds no documents and
empties the collection. The chosen form is safe to run again except
between the copy and the end of the delete, where the route says to
finish the delete on the source first. The runner's error says it too,
after any failure between that copy and the end of its deletes as the
route prints them (just before the copy, the runner counts the target
and the source documents the copy selects; after a failure while the
copy runs, a write-concern error included, the advice says how to tell
from the target's count whether the copy finished, and a drop of the
source that throws is reported as one that may not have finished; before
any delete or drop by hand, the advice says writes to both collections
must still be stopped, and before counting, to check with a printed
`$currentOp` query, which matches only this database and only an
aggregate whose last stage writes into the collection, that the copy is
no longer running, since MongoDB finishes an `$out` after the connection
drops, and to check again after any `killOp`, since it is not immediate;
when the source held none of the copy's documents, a re-run also needs
that check and that nothing wrote to either collection; when that is not
certain, to delete nothing from either collection and not run again
until the two are settled by hand, leaving in the source every document
the copy does not select, and of those it selects only the ones the
target does not hold, since the next run copies the source again; the
count it gives reads only writes a majority of the replica set has made,
and when a count read fails, a count is not exact, or the two
collections have different collations, it gives no count route and says
to settle both collections by hand, and a failed count read does not
stop the copy; both count conclusions hold only if nothing wrote to or
deleted from either collection since the apply started), including a
move of several groups, which gets one delete per `$unionWith` stage; it
adds nothing for hand-written copies of another shape, including a copy
with an after-check or with a stage after its `$match` other than
`$set`, `$addFields` or `$unset`; a copy of another shape that writes
with `$out` or `$merge` and stops on a thrown error is reported as
`MIGRATION.EXECUTION_FAILED`, saying it may have finished, to check that
it has ended, and to settle both collections by hand before running
again; the planner's own `$merge` move into a collection that is not
time-series is recognised and reported as before, since its `$merge`
matches by `_id` and a re-run is safe, and a copy with a check is told
that a re-run copies again unless postchecks and idempotency checks are
both on and its check shows it ran. The copy reads the source with the
time-series collection's collation, so the route gives each
`deleteDocuments` that collation (`{ locale: "simple" }` when it has
none), and the delete and its after-check select what the copy took,
whatever the filter. When the count shows the old number, the advice
says to count again after a moment, since a majority count can lag, and
that a re-run may still add the documents a second time. The move route
states the costs of this copy: it rewrites the whole collection, writes
to both collections stop for the whole apply, and `$out` cannot write
into a sharded collection. The time-series rename route under `migration
plan` prints the same form of copy, followed by the plan's drop of the
old collection, and, under both `db update` and `migration plan`, says
to stop writes to both collections until the apply succeeds, re-runs
included.

## Not covered

- **A model that is not a variant moves out of a shared collection
without `--rename`.** Its documents cannot be told apart from the other
model's, so they stay behind, and the model starts empty in its new
collection. The plan does not ask about it, as on `main`. The spec
defers this as a data migration needing its own design; it is in
`projects/migration-statements/deferred.md`.
- **Two collections or fields of identical shape that swap names.**
`migration plan` reports "No changes detected", because it compares a
hash of the storage layout before planning, and the hash does not
change. `db update` refuses the same change. This is the same known gap
as on SQL, and the upgrade note states it.
- **Two limits of the hand-written move, which the error states.** A
document written to the source between the copy and the delete is
deleted without being copied, so the error says to stop writes to both
collections until the apply succeeds, re-runs included. `$merge` matches
on `_id`, so the error says to check first that no `_id` is in both
collections. Handling either automatically would need a new mechanism.
- **The validator update's after-check compares only the
`$jsonSchema`.** This is on `main` and is in `deferred.md`.
- **The `true`/`false` enum swap is covered by planner tests only.** No
contract can currently hold an enum member mapped to `false`, because
canonicalization drops it (TML-3832).

## Other changes in this pull request

- The ORM's tests no longer assert the first line of
`CLI.CONSENT_REQUIRED`. That sentence is written and tested by
`@prisma/cli-engine` in another repository, and every change to its
wording forced edits here. The tests still assert what the ORM supplies:
the code, the reason, the next steps and the unanswered questions.
- Four changes to the database-neutral CLI package, the only ones under
`packages/1-framework`. Each is about the CLI's own text, with no
database concept added:
- Advice no database reaches any more is deleted: the swap text in
`keep-data-edit-advice.ts`, and the "member the new contract keeps"
branch in `plan-questions.ts`.
- A suggested fix in an error keeps the indentation of its lines
(`normalize-error.ts` trimmed both ends of each line). The MongoDB move
steps need it, and no other message a user can see has indented lines.
- The error for a missing contract snapshot names `--advance-ref db` in
its steps and suggested commands, where `main` printed the placeholder
`<name>`, and says that `db` is the development database's ref, so a run
against any other database gives another ref name (`cli-errors.ts`). The
numbered steps a data-loss question shows are the same text, so they
changed the same way.
- When a data-loss question is asked and the contract the database is at
is unknown, its advice now says that a change of a stored name alone is
then planned with no question, and a change of a name is answered with
`--rename` (`plan-questions.ts`, all targets).
- The public API lists (`api.txt`) gain `rawAggregate`'s options, the
runner option `policiesInForce` (which replaces 8.0.0-rc.25's
`checkedPolicies`), and five helpers from the MongoDB family's
`schema-verify` entry point (`isDisabledChangeStream`,
`isSimpleCollation`, `reportedCappedMax`, `reportedCappedSize`,
`reportsValidator`). The helpers are for internal use: they let the
target's `createCollection` after-check and the schema verifier share
one rule for what MongoDB reports, and the public package republishes
every family entry point. They also gain `codecStoresValue` from
`./contract/data-type`, beside `bsonTypesOfCodec`, which the enum swap
route uses to suggest only a temporary value the enum's codec can store.
- ADR 188 now records the order of operation kinds, that it stands in
for dependencies the plan does not model, when a write may skip
validation, and the time-series copy with the steps to take before
running it again. ADR 324, the Migration System and MongoDB Family docs,
the error reference and the `prisma-8` skill describe the end state. The
upgrade note is in
`upgrade-instructions/pending/mongo-stored-name-renames/`.
- The project's handover notes are removed, and
`projects/migration-statements/plan.md` lists every merged piece of the
project.

## How it was checked

- Planner tests in `packages/3-targets/mongo/1-target/test/`: the
`mongo-planner.stored-name*`, `mongo-planner.enum-stored-values*`,
`mongo-planner.document-moves*` and `mongo-planner.embedded-keys` files,
`mongo-model-matching` and `mongo-document-moves`.
- Runner tests against a live MongoDB (mongodb-memory-server) in
`test/integration/test/mongo/target-runner/`:
`runner-stored-name-renames`, `runner-stored-name-reruns`,
`runner-document-moves*` and `runner-create-collection-reruns`,
including runs stopped part way and run again.
- CLI journeys in `test/integration/test/cli-journeys/`:
`stored-name-renames.mongo`, `stored-name-refusals.mongo`,
`stored-name-routes.mongo`, `stored-name-shared-collections.mongo` and
`stored-name-db-update.mongo`. They follow every printed two-migration
route and move to the end and read the documents back.
- Thirty-three rounds of hands-on testing with the CLI against
mongodb-memory-server, following every printed route. The reports are in
`projects/migration-statements/manual-qa-reports/`.

## API changes

- `@prisma/orm-family-mongo (not exported): RawAggregateOptions`,
`@prisma/orm-family-mongo/query-ast/execution: RawAggregateCommand`,
`@prisma/orm-family-mongo/query-ast: RawAggregateCommand`,
`@prisma/orm-family-mongo/lowering: MongoLoweredDraft` and
`@prisma/orm-family-mongo/wire: AggregateWireCommand`: a raw aggregate
can now carry `bypassDocumentValidation`, from the query AST through
lowering to the wire command, so a document move can copy past a
validator that a later operation replaces.
- `@prisma/orm-family-mongo/query-ast/execution: RawDeleteManyCommand`,
`@prisma/orm-family-mongo/query-ast: RawDeleteManyCommand`,
`@prisma/orm-family-mongo/wire: DeleteManyWireCommand` and the
`collation` of `RawAggregateCommand`, `MongoLoweredDraft` and
`AggregateWireCommand`: raw deletes and raw aggregates can carry a
`collation`, so a move's delete selects with the collation its copy
reads with.
- `@prisma/orm-family-mongo (not exported): RawDeleteManyOptions`: new
options type of `RawDeleteManyCommand`, holding its `collation`.
- `@prisma/orm-target-mongo (not exported): DeleteDocumentsOptions`:
gains the optional `collation` of `deleteDocuments`.
- `@prisma/orm-family-mongo`: its `api-breaks.json` takes new
fingerprints for records `main` already holds, for
`buildMongoContractFromDefinition` (prisma#31185) and for the
exports prisma#31218 recorded, which the compatibility check judges
again because a declaration it uses changed on this branch. It also
records `MongoRuntime` and `createMongoRuntime` (`./runtime`): this PR
adds optional `bypassDocumentValidation` and `collation` to
`RawAggregateCommand` and an optional `collation` to
`RawDeleteManyCommand`, and `prepare`'s return type checks the plan's
command against unions of those classes, so the comparison with
8.0.0-rc.25 reports a break, recorded as allowed: the change only adds
optional members, and code written for that release still compiles.
- `@prisma/orm-target-mongo`: its `api-breaks.json` takes the
fingerprints this branch gives the exports prisma#31218 recorded
there, because this PR changes `MongoMigrationRunnerExecuteOptions` and
the planner the records depend on.
- `@prisma/orm-mongo`: its new `api-breaks.json` records
`MongoPrepareMember`. Its return type `MongoPreparedFrom` resolves a
plan through `MongoPreparedFor`, which checks the plan's command against
unions of the raw command classes this PR changes, so the comparison
with 8.0.0-rc.25 reports a break, recorded as allowed: the change only
adds optional members, and code written for that release still compiles.
- `@prisma/orm-target-mongo/target/migration: deleteDocuments` and
`@prisma/orm-target-mongo/target: deleteDocuments`: the
`deleteDocuments` factory takes a `collation` option, which the move
route prints.
- `@prisma/orm-family-mongo/family/schema-verify: collationsMatch` and
`@prisma/orm-family-mongo/family: collationsMatch`: new; the verifier's
rule for whether two collations match, shared with the runner.
- `@prisma/orm-target-mongo/target/migration: rawAggregate` and
`@prisma/orm-target-mongo/target: rawAggregate`: the `rawAggregate`
factory takes the same option, as `rawUpdateMany` already did.
- `@prisma/orm-family-mongo/contract/data-type: codecStoresValue`: new;
tells whether a codec can store a value, used to pick a temporary value
when enum stored values are swapped.
- `@prisma/orm-family-mongo/family/schema-verify:
isDisabledChangeStream`, `@prisma/orm-family-mongo/family/schema-verify:
isSimpleCollation`, `@prisma/orm-family-mongo/family/schema-verify:
reportedCappedMax`, `@prisma/orm-family-mongo/family/schema-verify:
reportedCappedSize`, `@prisma/orm-family-mongo/family/schema-verify:
reportsValidator` and `@prisma/orm-family-mongo/family:
isDisabledChangeStream`, `@prisma/orm-family-mongo/family:
isSimpleCollation`, `@prisma/orm-family-mongo/family:
reportedCappedMax`, `@prisma/orm-family-mongo/family:
reportedCappedSize`, `@prisma/orm-family-mongo/family:
reportsValidator`: now exported, so the target's `createCollection`
after-check and the schema verifier share one rule for what MongoDB
reports. They are for internal use.
- `@prisma/orm-target-mongo (not exported): MongoPlanOptions`,
`@prisma/orm-target-mongo/target/control: MongoMigrationPlanner` and
`@prisma/orm-target-mongo/target: MongoMigrationPlanner`: the planner
takes the stored-name rename statements and refuses the changes it
cannot carry out.
- `@prisma/orm-target-mongo/target/control:
MongoMigrationRunnerExecuteOptions` and
`@prisma/orm-target-mongo/target: MongoMigrationRunnerExecuteOptions`:
the option `checkedPolicies`, released in 8.0.0-rc.25, is renamed
`policiesInForce`, and every contract space's runner now receives it, so
its advice offers only routes the policy permits; the runner itself
guards only the application space's marker with it. Code that passes
`checkedPolicies` must rename it, as the upgrade note says. The
compatibility check cannot see a renamed optional property, so the
existing records for `MongoMigrationRunner` and
`MongoMigrationRunnerExecuteOptions` name it in their reasons.

## Alternatives considered

- **Keep the consent prompt and the by-hand rename.** ADR 324 rejects
this for every database: a user who changed `@@map` either lost the
documents or renamed the collection by hand.
- **Run the migration in a MongoDB transaction.** Collection commands
such as `renameCollection` cannot run inside one, and transactions need
a replica set.
- **Record each operation's progress so a stopped chain can resume.**
[ADR
188](docs/architecture%20docs/adrs/ADR%20188%20-%20MongoDB%20migration%20operation%20model.md)
makes a migration only self-contained operations, each checking the
database before and after, with no progress record.
- **Copy the moving model's documents with validation on.** In some
plans no position works: before the source's rewrites, the target's old
validator rejects the copy; after them, the rewrites have already
changed the documents. Ordering the plan by collection does not help,
because the target's operations would also have to come before the
source's.
- **Ask about the documents a model leaves behind in a shared
collection.** A question must belong to an operation that loses data,
and here the plan may have none. It would also need a new kind of
data-loss question in the CLI framework.
- **Print a query that finds which source documents a stopped
time-series copy took.** Each version had a case it got wrong: a
time-series collection does not keep `_id` unique, sorts the keys of an
object `metaField`, and keeps no earlier form of a document that changed
after the copy. When the user cannot be sure nothing wrote to either
collection, the advice says to delete nothing and settle the two
collections by hand.

Closes TML-3840.

Agent: gandhi-65

---------

Signed-off-by: willbot <[email protected]>
Signed-off-by: Will Madden <[email protected]>
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