github prisma/orm v8.0.0-rc.25

latest release: v8.0.0-rc.25-dev.2
pre-release50 minutes ago

v8.0.0-rc.25

A database can now record how it may change and what data it protects, and the CLI refuses a migration or update that breaks those rules. MariaDB gets a client of its own, and MySQL gains the ORM's aggregates. Int, BigInt, Float, Decimal, String, Boolean, Bytes and Json are convenience types on every database. SQL clients run nested transactions with tx.transaction(callback), and an ORM write inside a transaction is atomic. On PostgreSQL and SQLite, a changed @@map, @map or enum stored value is planned as a rename. Nested writes gain onConflict, variants of a polymorphic model, a disconnect that applies its criteria, and update and delete of one related row. prisma orm init --target takes any target package by name.

The upgrade recipes for this hop: the app recipe and the extension recipe. Each breaking change below names the change ids to look for in them. The examples write the ORM client as db.orm.public.<Model>, the PostgreSQL form; on SQLite, MySQL and MariaDB it is db.orm.<Model>. After upgrading, run prisma contract emit once: the generated contract.d.ts now imports from one module of the target package, SQL contracts record two new capabilities, and MySQL and MariaDB contracts gain aggregate types.

Breaking changes

  • pg and @types/pg are peer dependencies. @prisma/orm-postgres, @prisma/orm-target-postgres and @prisma/orm-extension-supabase no longer install their own copy of pg and @types/pg. Add "pg": "^8.22.0" to your dependencies and "@types/pg": "^8.20.0" to your dev dependencies before you install the upgrade. This fixes a Pool from your own pg not being accepted by the client when the two @types/pg versions differed. See pg-is-a-peer-dependency in the app recipe and the extension recipe, and extension-importing-pg-peers-it in the extension recipe. (#31060)

  • temporal-polyfill must be 1.0.8 or later. Every database package that requires temporal-polyfill as a peer dependency now requires ^1.0.8, where it required ^1.0.4. A project or extension package that pins an older 1.0.x version updates it. See temporal-polyfill-peer-range-moves-to-1-0-8 in the app recipe and the extension recipe. (#31045)

  • PostgreSQL connections no longer set lc_monetary=C. This lets a pooled Prisma Postgres URL connect. If you use money columns, run SHOW lc_monetary as the application's role, outside Prisma. If it is not C, POSIX or en_US, run ALTER ROLE <role> SET lc_monetary = 'C' before you deploy the upgrade; otherwise a money read fails with RUNTIME.LC_MONETARY_NOT_C. Under a locale with no or three fraction digits, writes made before the change are stored wrong, so make the change first. See postgres-lc-monetary-not-set in the app recipe. (#31081)

  • The config type is PrismaConfig. The type defineConfig returns is renamed from PrismaNextConfig to PrismaConfig, with no alias. The language server's diagnostic PRISMA_NEXT_INTERPRETATION_FAILED is now PRISMA_INTERPRETATION_FAILED. See config-type-renamed-to-prisma-config in the app recipe and the extension recipe. (#31062)

    Before:

    import type { PrismaNextConfig } from '@prisma/orm-toolchain/cli/config-types';
    const config: PrismaNextConfig<'sql', 'postgres'> = defineConfig({ /* ... */ });

    After:

    import type { PrismaConfig } from '@prisma/orm-toolchain/cli/config-types';
    const config: PrismaConfig<'sql', 'postgres'> = defineConfig({ /* ... */ });
  • Generated files import from the module the target package names. A generated contract.d.ts now imports all its types from one module, such as @prisma/orm-postgres/contract-types; run prisma contract emit to regenerate it. A config that you assemble from the framework's own defineConfig, not a target package's, must set contract.typesModule and migrations.module, or commands fail with CONFIG.CONTRACT_TYPES_MODULE_MISSING and CONFIG.MIGRATION_MODULE_MISSING. Control API callers pass typesModule to emit and renderContractDts, and the projectDir option is gone. @prisma/orm-toolchain/publish-surface and its two sub-entries are removed. Extension authors: the emitter, migration renderer and MySQL config factory take the module names too. See contract-types-import-from-the-target-package, hand-assembled-config-names-generated-file-modules, control-api-takes-types-module and toolchain-publish-surface-entrypoints-removed in the app recipe, and target-package-names-generated-file-modules, extension-config-names-generated-file-modules, family-imports-are-import-requirements, migration-renderer-takes-the-migration-module, emitter-takes-the-types-module, mysql-config-components-carry-family-and-modules, control-api-takes-types-module, component-type-import-module-is-not-a-literal-type and toolchain-publish-surface-entrypoints-removed in the extension recipe. (#31078)

  • On PostgreSQL and SQLite, a changed stored name is planned as a rename. When a model, field or enum member keeps its name and only its @@map, @map or stored value changes, migration plan and db update now rename the table or column, or replace the stored value, without asking. A script that passed --delete for such a change now fails with CLI.CONSENT_UNUSED; remove the flag. To get an empty table under the new name, remove the model in one migration and add it back in the next. Swaps, chains and takeovers of table and column names are refused with MIGRATION.PLANNING_FAILED, and so are enum members that swap stored values or take the stored value of a removed member; make them in two migrations: the first moves every name involved to a name nothing uses, and the second moves them to the final names. Chains of enum stored values are planned. A table that still has the lowered name an earlier release gave a model with no @@map is renamed to the model name; add @@map to keep the old name. MySQL and MongoDB plan these changes as before. See sql-stored-name-change-is-a-rename, sql-stored-name-delete-is-unused, sql-stored-name-empty-table, sql-stored-name-swaps-refused and sql-lowered-table-names-renamed in the app recipe. Extension authors who call the SQL family's statement planning see schema-tables-same-name, plan-statements-plans-stored-name-renames, subjects-of-calls-storage-renames and stored-value-keep-data-edit-removed in the extension recipe. (#31088)

    Before:

    prisma migration plan --name move-users --delete User

    After:

    prisma migration plan --name move-users
  • sql.String(n) is now sql.Varchar(n), and PostgreSQL's jsonColumn is plainJsonColumn. sql.String(n) still works as a deprecated alias that warns with PSL_DEPRECATED_SCALAR_NAME, in PSL and as type.sql.String(n) in TypeScript. The PostgreSQL column helper jsonColumn is removed; import plainJsonColumn. No contract changes. See psl-renamed-sql-string, ts-renamed-sql-string and ts-renamed-postgres-json-column-helper in the app recipe, and ts-postgres-explicit-json-type in the extension recipe. (#31065)

    Before:

    model Label {
      id   Int            @id
      name sql.String(50)
    }

    After:

    model Label {
      id   Int             @id
      name sql.Varchar(50)
    }
  • On MongoDB, Int64 is now Int64BigInt. Int64 still works in PSL as a deprecated alias that warns. In a TypeScript contract, type.Int64() is removed; write type.BigInt() or type.Int64BigInt(). No contract changes. See psl-renamed-mongo-int64 and ts-removed-mongo-int64-helper in the app recipe and the extension recipe. (#31067)

    Before:

    model Post {
      id    ObjectId @id @map("_id")
      views Int64
    }

    After:

    model Post {
      id    ObjectId @id @map("_id")
      views BigInt
    }
  • On SQLite, Decimal and BigIntNumber change codec, and integers are checked. A Decimal field now uses its own codec, sqlite/decimal@1, and refuses text that is not a decimal. BigIntNumber is a deprecated alias of IntegerNumber; write BigInt(as: number). Both change the contract's storage hash, so re-emit and sign the database: with migrations, migration plan --from <latest migration> then db migrate; without, db update. No column changes. An Int field now refuses to write, and fails to read, a number that is not an integer within ±(2^53 − 1). The column helpers integerColumn, bigintColumn and jsonColumn are renamed integerNumberColumn, integerBigIntColumn and plainJsonColumn. The recipe has queries that find rows the new checks refuse. See sqlite-decimal-codec, ts-sqlite-decimal-codec, sqlite-bigintnumber-deprecated, sqlite-integer-safe-range and ts-renamed-sqlite-column-helpers in the app recipe and the extension recipe. (#31086)

  • Re-emit MySQL and MariaDB contracts. The MySQL target now supplies the ORM's aggregates and has codecs for the new convenience types. Run prisma contract emit so contract.d.ts carries their types; the contract's hashes do not change. Errors from MySQL's shared code no longer carry meta.target; read db.stack.target.targetId instead. Extension authors: the MySQL driver factories take the target's runtime metadata and its CHECK error numbers, and a hand-written MySQL codec descriptor needs wrapParameter. See re-emit-mysql-contract-for-aggregates, mysql-errors-drop-meta-target and mysql-reemit-contract in the app recipe, and mysql-driver-factories-take-the-target and mysql-codec-descriptor-wrap-parameter in the extension recipe. (#31082, #31109)

  • SQL contracts record two include capabilities, and a nullable unique key no longer identifies a row. Run prisma contract emit to record sql.outerReferencesInDerivedTables and sql.jsonAggWithoutTruncation; a contract that is not re-emitted keeps working. A table whose only unique key has a nullable column now has no row identity, so update(), delete() and writes followed by .include(...) on it fail with ORM.ROW_IDENTITY_MISSING. Give such a table a primary key, or make the key's fields required. Extension authors with an SQL adapter report the three include capabilities. See re-emit-for-include-capabilities and nullable-unique-key-is-no-row-identity in the app recipe, and adapters-report-include-capabilities in the extension recipe. (#31058)

  • contract emit refuses a TypeScript contract built for another target. A contract that imports defineContract from another target's package, such as SQLite's in a PostgreSQL project, now fails with CONTRACT.TARGET_MISMATCH, whose fix names the right module. It used to emit and then fail when the client loaded it. typescriptContractFromPath from @prisma/orm-family-sql/contract-ts/config-types now takes the target and its contract-builder module. See typescript-contract-for-another-target-refused and typescript-contract-from-path-requires-target in the app recipe, and typescript-contract-from-path-requires-target in the extension recipe. (#31091)

  • A TypeScript hasOne relation needs a unique key on the target. rel.hasOne(Target, { by }) now fails with CONTRACT.RELATION_INVALID unless a primary key, unique constraint or unique index without where covers exactly the by fields. Make them unique, or use rel.hasMany. PSL already refused this. See has-one-key-must-be-unique in the app recipe and the extension recipe. (#31030)

  • Single-table variants keep their foreign keys, and refuse uniques and indexes over the whole table. A relation on a variant that shares its base model's table now stores its foreign key and backing index; both used to be dropped. @unique, @@unique and most @@index without where: on such a variant now fail with PSL_UNSCOPED_INDEX_ON_STI_VARIANT, whose message gives the partial index to write instead. Re-emit, then plan and apply a migration. See sti-variant-unscoped-index-refused and sti-variant-foreign-keys-stored in the app recipe. (#31040)

  • A PSL schema must be valid UTF-8. A schema file with bytes in another encoding now fails with PSL_SCHEMA_READ_FAILED, naming the file. Before, each bad byte became U+FFFD and the file loaded. Reopen the file in its original encoding, such as Windows-1252, and save it as UTF-8. See psl-schema-must-be-utf8 in the app recipe. (#30202)

  • SQL builder comparisons check values against the column's type. In fns.eq, ne, gt, gte, lt, lte, in and notIn, a value compared with an enum column, or any column whose type is narrower than its codec's, must have the column's type. A misspelled member, a plain string or a string[] is now a type error. Narrow the value first, or compare through fns.raw to match a value the enum no longer lists. See sql-builder-enum-comparison-values-are-checked in the app recipe. (#31019)

  • Nested relation mutation errors use the general ORM codes. ORM.RELATION_MUTATION_INVALID is now ORM.ARGUMENT_INVALID, and ORM.RELATION_MUTATION_UNSUPPORTED is now ORM.OPERATION_UNSUPPORTED; meta is unchanged. createAll and createAndCount with onConflict: 'skip' now refuse, before any statement runs, a row that gives no value for any key the option watches, and a table with no key at all, with ORM.ARGUMENT_INVALID. See relation-mutation-error-codes-merged, create-all-skip-refuses-rows-without-conflict-key and create-all-skip-refuses-tables-without-keys in the app recipe. (#31031)

  • disconnect in update() data changed in three ways. On a relation whose foreign key is required, r.disconnect() is now a type error and is refused with ORM.OPERATION_UNSUPPORTED (meta.reason: 'required-foreign-key') before any statement runs; use connect to another row, or delete. On a many-to-one relation, r.disconnect(criteria) now unlinks only when the linked row matches the criteria; it used to ignore them. r.disconnect([]) now disconnects nothing; it used to act as r.disconnect(). See disconnect-on-required-relation-refused, to-one-disconnect-criteria-applied and disconnect-empty-criteria-disconnects-nothing in the app recipe. (#31072, #31095)

  • A nested create on a polymorphic model names its variant. In a relation callback whose target is a polymorphic base model, r.create(data) no longer compiles. Write r.variant(value).create(data) and drop the discriminator field from the data. create() on a variant stored in its own table, without the returning capability, now names create() in its ORM.CAPABILITY_MISSING error, not createAll(). See nested-create-on-polymorphic-target-needs-variant and variant-create-without-returning-names-create in the app recipe. (#31029)

    Before:

    await db.orm.public.Project.where({ id: 1 }).update({
      tasks: (tasks) => tasks.create({ title: 'Crash on login', type: 'bug' }),
    });

    After:

    await db.orm.public.Project.where({ id: 1 }).update({
      tasks: (tasks) => tasks.variant('bug').create({ title: 'Crash on login' }),
    });
  • Inside a transaction, other work on tx is refused while an ORM write of several statements runs. Such a write, for example a create with a nested relation, now runs in a savepoint. Work sent on the same tx while it runs, such as a second call in Promise.all, rejects with RUNTIME.TRANSACTION_SUSPENDED. Await the write before sending the other work. When such a write hits an error that ends the whole transaction, such as a deadlock on MySQL or MariaDB, it now rejects with RUNTIME.TRANSACTION_ROLLBACK_FAILED and carries the database's error as cause; code that retries on a deadlock reads it from there. See orm-write-inside-transaction-suspends-tx in the app recipe and the extension recipe. (#31121)

    Before:

    await db.transaction(async (tx) => {
      await Promise.all([
        tx.orm.public.Post.create({ title, author: (author) => author.create(user) }),
        tx.execute(plan),
      ]);
    });

    After:

    await db.transaction(async (tx) => {
      await tx.orm.public.Post.create({ title, author: (author) => author.create(user) });
      await tx.execute(plan);
    });
  • update() data refuses a foreign key together with a callback on its relation. Data that sets a foreign key the record holds, such as authorId, and also has a callback on that relation, such as author, is refused with ORM.ARGUMENT_INVALID (meta.problem: 'foreign-key-with-relation-mutation') before any statement runs. It used to run, and a create, connect or disconnect callback overwrote the foreign key. Keep one of the two, or make two calls. See foreign-key-with-relation-callback-refused in the app recipe and the extension recipe. (#31100)

  • __proto__ is refused as a name, and a JSON default with a __proto__ key changes the storage hash. A contract now refuses a namespace, model, table, column, field, enum, value object, collection or root named __proto__ with CONTRACT.NAME_UNUSABLE_AS_KEY (PSL_STORED_NAME_UNSUPPORTED in a MongoDB schema); before, the entry was dropped or the contract came out wrong. One exception: in a MongoDB PSL contract, an enum named __proto__ is not refused but left out of the contract without an error, together with every field typed by it. Choose another name. A SQL builder select alias __proto__ is refused with RUNTIME.AST_INVALID. A JSON column default that has a __proto__ key now keeps that key in contract.json; re-emit, then plan and apply a migration. See sql-proto-names-refused, mongo-proto-names-refused and json-default-proto-key-kept in the app recipe. (#31148, #31173)

  • Update data cannot set the discriminator of a polymorphic model. Setting it is now a type error, and it is refused with ORM.FIELD_IMMUTABLE. Before, it changed only the base table and left the variant's rows inconsistent. Remove the discriminator from update data; to move a row to another variant, delete it and create it as that variant. See update-data-refuses-discriminator in the app recipe. (#31068)

  • prisma db migrate advances the db ref by default. After a successful apply, db migrate now moves the db ref (migrations/app/refs/db.json) to the contract the database is at, as db init and db update do, so the next migration plan starts from what was applied. It does so when the connection comes from prisma.config.ts and the CLI does not detect CI. With --db <url> or in CI it advances nothing, and in CI it says so with MIGRATION.REF_NOT_ADVANCED_IN_CI. A deploy that runs db migrate from the config outside a CI runner, such as a container entrypoint or a release command, now rewrites that tracked file: pass the new --no-advance-ref, or --db. Remove --advance-ref db from development commands that read the connection from the config. A ref that cannot be written is now the warning MIGRATION.REF_NOT_WRITTEN and the command exits 0; it used to fail the command after the migrations had applied. Passing --advance-ref and --no-advance-ref together is refused with CLI.ADVANCE_REF_ARG_CONFLICT. See db-migrate-advances-db-ref in the app recipe. (#31169)

    Before:

    prisma db migrate --advance-ref db

    After:

    prisma db migrate
  • The CLI engine is @prisma/cli-engine 0.10.4, and its consent error has one fixed first line. @prisma/orm-toolchain now requires exactly 0.10.4, up from 0.10.0; a project that declares @prisma/cli-engine itself moves to 0.10.4. When a command stops because it needs consent it cannot ask for, the first line of CLI.CONSENT_REQUIRED is now This command requires explicit consent, but it was not provided., or, under --yes, This command requires explicit consent for which --yes is not sufficient. It no longer names the subject or quotes the question. The suggested commands, meta, the code and the exit code are unchanged, and so is the why line of a refused migration or update; the error that --confirm answers gains a why line that holds the question. A script or test that matched the old first line reads the error's code, why and meta instead. See engine-pin-moves-to-0-10-4 and consent-required-summary-is-one-fixed-sentence in the app recipe and the extension recipe. (#31179)

    Before:

    ✘ [CLI.CONSENT_REQUIRED] "Shop.legacy" needs a statement, and the session is not interactive.
    

    After:

    ✘ [CLI.CONSENT_REQUIRED] This command requires explicit consent, but it was not provided.
    
  • MongoDB plans now ask about, and rewrite, changes inside documents. A field a value object or embedded model loses, an enum stored value that is removed, and a variant that is removed or whose discriminator value changes are now questions, answered with --rename, --delete or --convert. A script that runs with --yes and no statements fails with CLI.CONSENT_REQUIRED; add the statements it lists. A new required field inside a value object or embedded model is filled with a temporary value unless --backfill names it. See mongo-nested-removals-are-asked, mongo-nested-statements-are-planned and mongo-nested-required-field-gets-temporary-value in the app recipe. (#31061)

  • The control API's migrate takes the target ref whole. MigrateOptions no longer takes refHash, refInvariants and refName; pass target: { kind: 'ref', ref: { name, ...entry } } or target: { kind: 'hash', hash }. DbSignOptions requires invocation. CLI users are not affected. See migrate-options-ref, db-sign-invocation and permit-policy-change in the app recipe. (#30926)

  • Extension authors: migration runners record database policies, and families name access changes. A target's migration runner writes databasePolicies into the marker and checks the policies it was given under its lock. ControlFamilyInstance and SqlControlTargetDescriptor gain a required accessChangesOf(operations), and planMigration and resolveRecordedPath take it too; a target with no operation that changes access returns []. See runner-records-database-policies, control-family-access-changes-of and aggregate-planner-access-changes-of in the extension recipe. (#30926, #31087)

  • Extension authors: transaction contexts have transaction, and an activity handle's transaction takes a callback and is always there. TransactionContext, PostgresTransactionContext, MysqlTransactionContext, SqliteTransactionContext and SupabaseTransactionContext have a required transaction(fn) member, so a context an extension builds by hand needs one. TransactionSettlementState gains closed and abandon(). An activity handle's transaction(fn, options) now runs fn through withTransaction instead of returning a transaction to commit; SqlRuntimeBase.ownTransaction is removed; and rollback() after a commit rejects with RUNTIME.TRANSACTION_CLOSED. An ActivityHandle always has transaction(fn, options) and a new inTransaction() member, so a handle built by hand needs both, and ActivityRoute.transaction is never undefined. See transaction-context-has-transaction, postgres-transaction-context-has-transaction, transaction-settlement-state-has-closed-and-abandon, facade-transaction-contexts-have-transaction, supabase-transaction-context-has-transaction, activity-handle-transaction-takes-callback, sql-runtime-base-own-transaction-removed, orm-runtime-queryable-transaction-removed, rollback-after-commit-rejects, activity-handle-transaction-and-in-transaction-required and activity-route-transaction-always-defined in the extension recipe. (#31073, #31106, #31120, #31121)

  • Extension authors: the relation mutator types take Writes and DeleteDisabled. The boolean type parameter FilteredWritesDisabled of RelationMutator, from @prisma/orm-family-sql/orm-client, is replaced by Writes extends 'many' | 'one' | 'none', and the type gains the parameters NsId, ConflictActions and DeleteDisabled. VariantRelationMutator is new and takes the same parameters. Code that passes the argument replaces false with 'many', and true with 'one' or 'none'. See relation-mutator-writes-parameter in the extension recipe. (#31096, #31100)

  • Extension authors: MongoDB ORM collections can be prepared. A hand-written MongoCollection needs a prepared member, and its limit and offset take a placeholder. MongoPrepareMember moved to @prisma/orm-mongo/runtime and takes the contract. MongoWhereFilter values can be placeholders, and compileMongoQuery takes no type argument. See mongo-collection-has-prepared, mongo-prepare-member-moved, mongo-where-filter-takes-placeholders and compile-mongo-query-has-no-row-type in the extension recipe. (#31054)

Features

  • A database can record a change policy and a data protection policy. A ref file declares them under policies: change lists migrate (db migrate), reconcile (db update, db sign) or both, and dataProtection sets dataLoss and accessWidening to …-forbidden, …-with-consent or …-permitted. db migrate --to <ref> and db update --to <ref> refuse a ref whose policies differ from the database's with MIGRATION.POLICY_MISMATCH, unless --permit-policy-change consents to writing them. A command the change policy does not allow fails with MIGRATION.CHANGE_POLICY_FORBIDS. A database with no recorded policy behaves as before. (#30926)
  • Data protection is enforced. Where a setting is forbidden, db update and db migrate refuse an operation that loses data, or one that the target counts as changing who can read or write data, with MIGRATION.DATA_PROTECTION_FORBIDS, before anything runs; --delete, --allow and a typed answer cannot permit it, and --rename still applies. migration plan --to <ref> refuses to write a migration the ref's policy forbids. Where a setting is permitted, db update asks nothing about it. The refusal's advice names the policy that refused, says how to plan the change again without losing data, and tells you not to edit an extension's migrations. On PostgreSQL, only two operations count as access changes: disabling row-level security, and dropping a row-level-security policy. Creating a policy does not count, even a permissive one that grants access. Nor does a policy that the same plan or migration drops and creates again, under the same name or generated-name prefix, whatever its new roles, command, USING, WITH CHECK or permissive setting say, so a replacement that widens access is not refused. A rawSql operation is not read either, so SQL in a hand-written migration that disables row-level security or drops a policy is not refused. SQLite, MySQL, MariaDB and MongoDB count no operation as an access change, so accessWidening: access-widening-forbidden refuses nothing on them. (#31087, #31131)
  • MariaDB has a client: mariadb() from @prisma/orm-mariadb/runtime runs ORM reads and writes, takes every option mysql() takes, and accepts mariadb:// and mysql:// URLs. @prisma/orm-mariadb/contract-builder writes MariaDB contracts in TypeScript. On a database that cannot run the ORM's one-query include, such as MariaDB, the ORM loads each include with one query per relation. (#31058, #31082, #31091)
  • The ORM's aggregates, count, sum, avg, min and max, run on MySQL and MariaDB in aggregate(), groupBy(), combine() and scalar includes. (#31082)
  • Int, BigInt, Float, Decimal, String, Boolean, Bytes and Json are convenience types on PostgreSQL, MongoDB, SQLite, MySQL and MariaDB. Each chooses one explicit type, and takes options such as BigInt(as: number) and String(storage: text). MySQL and MariaDB gain Float, Decimal, Boolean, Bytes and Json; SQLite gains Boolean; MongoDB gains BigInt, Decimal and Bytes. A SQLite BigInt field now reads the full 64-bit range. (#31067, #31086, #31109)
  • On PostgreSQL, Json(storage: jsonb) gives a jsonb column; Json still gives json. contract infer and contract print write a jsonb column as Json(storage: jsonb). (#31065)
  • SQL clients run nested transactions. Inside db.transaction(callback), tx.transaction(callback) runs in a savepoint, to any depth, on PostgreSQL, MySQL, MariaDB, SQLite and Supabase. When the inner callback throws, only its work is rolled back and tx stays usable, unless the error ended the whole transaction, as a deadlock does on MySQL and MariaDB; then tx.transaction(...) rejects with RUNTIME.TRANSACTION_ROLLBACK_FAILED, with the callback's error as cause, and tx refuses further statements with RUNTIME.TRANSACTION_CLOSED. The inner callback receives the same kind of tx, with orm, sql and the other members. While it runs, the outer tx refuses statements with RUNTIME.TRANSACTION_SUSPENDED. (#31053, #31106, #31120)
  • A nested create takes { onConflict, conflictOn? }. onConflict: 'connect' inserts a row that does not collide and links an existing one that does, on every relation layout. onConflict: 'skip' leaves a colliding row as it is, on one-to-many relations. (#31031, #31070)
  • A relation callback can act on one variant of a polymorphic model: r.variant(value) has create, connect, disconnect, where, updateAll and deleteAll, each limited to rows of that variant. create writes a complete row, including a variant stored in its own table. (#31029, #31034, #31095)
  • A relation callback in update() data can update or delete one related row. On a to-many relation, r.where(filter).update(data) and r.where(filter).delete() change the first related row the filter matches. On a to-one relation, r.update(data) and r.delete() change the linked row, narrowed by where() if given. When no related row matches, nothing changes. delete is refused on a relation whose foreign key, held by the record, is required. (#31096, #31100)
  • An ORM write of several statements inside db.transaction(callback) is atomic: it runs in a savepoint, so a write that fails leaves none of its rows, and on PostgreSQL it no longer aborts the transaction. (#31121)
  • poolOptions.max sets the most connections the pool of postgres() and supabase() opens; the default stays 10. Set max: 1 behind a server-side pooler, such as a pooled Prisma Postgres URL. (#31138)
  • The control API's DbUpdateSuccess has migrationPlan: the --from and --to of a migration plan that moves the database to the run's target. Its types, MigrationPlanArguments, MigrationPlanArgument and MigrationPlanTargetArgument, are exported, and databaseStorageHash is deprecated in its favour. DbUpdateOptions takes an optional emittedContractHash. (#31174)
  • A MongoDB ORM read can be prepared once and run many times: the db.prepare callback can return db.orm.<collection>…prepared.all(), .first() or .firstOrThrow(), with placeholders in where, limit and offset. (#31054)
  • A pgvector column can hold vectors of any length: pgvector.Vector in PSL, or vector() in TypeScript, is PostgreSQL's vector type without a dimension, read as number[]. (#30664)
  • prisma orm init installs the target package first and writes the project from that package's init entrypoint, so the files come from the version you install. The files it writes are unchanged. It reports CLI.INIT_TARGET_PACKAGE_NOT_INSTALLED, CLI.INIT_CONTRIBUTION_UNAVAILABLE and CLI.INIT_AUTHORING_UNSUPPORTED when a package cannot set up a project. Extension authors: a package that adds a target can export an init entrypoint typed InitContribution from @prisma/orm-toolchain/cli/init-contribution; see target-package-exports-an-init-contribution in the extension recipe. (#31093)
  • prisma orm init --target takes the name of any target package that exports an init entrypoint and lists the prisma-orm-extension keyword, beside the short names postgres and mongodb. --target @prisma/orm-sqlite and --target @prisma/orm-mysql set up SQLite and MySQL projects, and the picker has an entry for another package. The --json result gains package, and its target is the package name for a package with no short name; a script that accepts only postgres and mongodb there needs a change. See init-target-takes-a-package-name in the app recipe and init-reaches-a-target-package-by-name in the extension recipe. (#31128)
  • A target package built outside this repository can emit a contract whose contract.d.ts compiles, because generated files import from the module the target package names. (#31078)
  • PSL accepts /* … */ block comments, as Prisma 6 and 7 do. (#30795)
  • MutationUpdateInput, the type update() takes, is exported from the orm-client entry, such as @prisma/orm-postgres/orm-client, as the docs say. (#30611)

Fixes

  • A pooled Prisma Postgres URL connects. (#31081)
  • With poolOptions: { max: 1 }, a transaction and a query sent together as a client's first calls no longer fail with CONTRACT.MARKER_READ_FAILED after 20 seconds, and a Supabase client on such a pool can run queries as a signed-in user. (#31146)
  • A PostgreSQL or MySQL URL that leaves the user or the host blank, such as postgres://:password@localhost/db, connects with the driver's default for the blank part. (#31066)
  • Names that every JavaScript object inherits, such as constructor, toString and valueOf, work as namespace, model, table, column and field names in contracts, the ORM client, the SQL builder, contract infer and migration planning. (#31148, #31173)
  • A statement started inside a transaction that has not reached the database when the transaction commits or rolls back is refused with RUNTIME.TRANSACTION_CLOSED. Before, it could run on its own after the ROLLBACK and be committed. (#30880)
  • A model whose primary key is also a foreign key to its parent can have an optional one-to-one relation to a child that does the same. contract emit used to fail with CONTRACT.VALIDATION_FAILED. (#30710)
  • Tables in an unbound PostgreSQL namespace are found through search_path again, instead of being queried as "__unbound__"."<table>". (#30723)
  • In the SQL builder, a column of the outer query used inside a subquery refers to the outer table, not to the inner table with the same column name. (#30727)
  • include works on a model with more than 50 columns on PostgreSQL, and more than 63 on older SQLite builds. (#30796)
  • On a collection such as db.orm.auth.User, select, distinct, distinctOn, cursor, whereUnique and conflictOn use the fields of that namespace's model when another namespace has a model with the same name. (#30810)
  • ilike and fullTextMatches in the SQL builder accept a nullable text column. (#30598)
  • The MongoDB ORM offers inc and mul on nullable number fields. (#30522)
  • A Date created in another JavaScript realm, such as a Jest test file, is accepted wherever a value is written. On MongoDB it used to be written as {}. (#30809)
  • A column reference passed to returnsRow() in a raw query keeps its codec parameters and array type, so such columns decode correctly. (#30973)
  • A where with tens of thousands of in values or or branches is built in milliseconds instead of seconds. (#30870)
  • The SQL runtime computes a statement's fingerprint only when telemetry() is read, instead of after every statement. (#30949)
  • Contract globs such as ./schema/*.prisma work on Windows. (#30872)
  • On MySQL, an ORM update or delete whose filter reads the table it writes now fails with RUNTIME.AST_UNSUPPORTED and says what to do, instead of the server's error 1093; code that matched error 1093 matches RUNTIME.AST_UNSUPPORTED. A contract file whose export is not a contract fails with CONTRACT.EXPORT_INVALID, naming the file, instead of crashing. (#31091)
  • Most prisma migration plan commands that the CLI prints now work. Errors, migration status, and the advice of db update, db init, db sign and db migrate now print the --from and --to the plan needs for where the database is, and repeat the flags you gave, such as --config and --permit-policy-change. Before, many of these commands failed with MIGRATION.PLAN_ORIGIN_UNKNOWN in a project with no db ref, or planned to the emitted contract when you had named a ref. When migrations on disk already lead the database to the target, or the database has not applied all of them and the advice is about one change such as a rename, the message says to apply them first with db migrate --to <contract>. When no plan can work, for example when the database's marker names a contract no migration produces, the message gives the reason and prints no command. Advice written by the SQL and MongoDB planners, such as how to fill a new required field, can still leave out --from; use the --from that migration status prints. (#31130, #31174)
  • prisma orm init no longer runs a failed pnpm install again with npm; it reports CLI.INIT_INSTALL_FAILED. (#31079)
  • The prisma-8 skill names published @prisma/orm-* packages instead of names that only resolve inside this repository, and no longer mentions packages and features that do not exist. (#31083)

Known problems

Neither problem is new in this release, and neither is fixed in it.

  • Inside db.transaction(async (tx) => ...), send every query through tx. On a PostgreSQL client with a single connection (a connection from postgresServerless().connect(), or postgres() given one pg.Client), a query sent through db while the transaction is open runs inside that transaction, and some calls, such as an update() of one row, wait and never finish. On a client with poolOptions: { max: 1 }, a query through db waits for the transaction's connection and fails after connectionTimeoutMillis, 20 seconds by default. A client whose pool has more than one connection runs the query outside the transaction.
  • A PostgreSQL database whose prisma_contract.ledger table was created by a release from before June 2026 lacks the space, migration_name and migration_hash columns that db migrate writes. Nothing adds them, so db migrate fails on such a database.

New contributors

Don't miss a new orm release

NewReleases is sending notifications on new releases.