github prisma/orm v8.0.0-rc.26

pre-releaseone hour ago

v8.0.0-rc.26

This release makes the changes to stored files and names that must land before 8.0. Every contract hash takes a new value, once, by rules that do not change again within Prisma 8, and every stored file names its format version. A contract lists the capabilities it requires, as keys prefixed by who provides them. On PostgreSQL and SQLite, Prisma's own tables move to their final names; MySQL, MariaDB and MongoDB move in a later release candidate. On every database, the contract marker is now the contract signature. The packages publish only the import paths users need, name each other as peer dependencies, and type every set of values that may grow so that a later 8.x release can add one. New in this release: @prisma/orm-better-auth, so Better Auth works with Prisma 8, ORM updates that set a column from another column or raw SQL, and commands that change the policies a ref declares.

The upgrade guides for this release: the app guide and the extension guide. Each opens with the order to do the steps in, which matters this time: some steps run with the release you are on now, and the deploy that ships the upgrade signs every database. Each breaking change below names the change ids to look for in the guides.

The ORM commands of this release need prisma 8.0.0-rc.37 or later, which is published shortly after this release. The prisma 8.0.0-rc.36 command runs the toolchain of 8.0.0-rc.25 beside this release's packages. Once the guides' scripts have upgraded a project, its commands fail with CONTRACT.VALIDATION_FAILED and "The contract file has no format version".

Breaking changes

  • Every contract hash changes, once. Each storage, profile and execution hash now covers only its own section of the contract, and no longer the target or the family. From 8.0 these rules do not change within Prisma 8. Before you upgrade, deploy every pending migration to every database with the release you are on. Then, in a release of its own with no new migration, run the contract-hash-inputs script from the app guide, which rewrites every hash in the project's stored files, and run prisma contract emit. In that release's deploy, run prisma db sign --no-advance-ref and then prisma db migrate against every database that existed before it. If the emitted contract's storage hash then differs from the one the script printed, the guide's step 4 adds one migration to that release, and the deploy signs each database at the migration before it. Extensions must be upgraded at the same time: an extension built for an earlier release fails to load with MIGRATION.DESCRIPTOR_HEAD_HASH_MISMATCH. See contract-hash-inputs in the app guide and the extension guide. (#31203)

  • A contract stores its required capabilities as requiredCapabilities, a sorted list of keys. Each key names who provides it: db. for the database and conn. for the connection. So sql.returning is db.returning, and sql.interactiveTransactions is conn.interactiveTransactions. This release refuses a contract.json or migration snapshot that still stores capabilities, with CONTRACT.VALIDATION_FAILED; the contract-hash-inputs script rewrites them. Code that reads a contract's capabilities changes too. See code-reads-required-capabilities and required-capabilities-as-list in the app guide, and extension-code-reads-required-capabilities and required-capabilities-as-list in the extension guide. (#31263, #31316)

    Before:

    if (contract.capabilities.sql.returning) { /* ... */ }

    After:

    if (contract.requiredCapabilities.includes('db.returning')) { /* ... */ }
  • A PostgreSQL contract lists the capabilities it requires. You write the list where the contract is written, from the lists postgres15 to postgres18 and postgresDriver. Without it, the contract requires the newest version's list and the driver's, and prisma contract emit warns with CONTRACT.REQUIRED_CAPABILITIES_NOT_LISTED; Prisma 8.0 requires the list. A config built with the core defineConfig gets no default, so add the list before you emit. transaction() needs conn.interactiveTransactions, which postgresDriver lists. prisma db sign, db verify, db migrate, db update and db init now refuse a database that does not provide what the contract requires, and every server older than PostgreSQL 15. Extension authors: descriptors no longer declare capabilities. See postgres-contract-lists-required-capabilities and the entries after it in the app guide, and extension-contract-lists-required-capabilities and the entries after it in the extension guide. (#31218)

    Before:

    orm: defineConfig({
      contract: './prisma/contract.prisma',
    }),

    After:

    import { defineConfig, postgres18, postgresDriver } from '@prisma/orm-postgres/config';
    
    orm: defineConfig({
      contract: {
        path: './prisma/contract.prisma',
        requiredCapabilities: [...postgres18, ...postgresDriver],
      },
    }),
  • On PostgreSQL, Prisma's own tables move to the schema prisma. The marker table is replaced by prisma.signatures, one row per contract space, and prisma.config, which holds the database's policies. The first command of this release that changes a database (db init, db update, db migrate or db sign) moves them and keeps every record. After that, only this release may change the database: a release candidate's command would apply every migration again. So move every service, deploy script and pipeline that runs prisma against a database to this release at once. Grants, reset scripts and queries that name prisma_contract or the marker table name the new tables, and a role other than the one that ran the move needs SELECT on prisma.signatures, and on prisma.config where it runs Prisma's commands. The schemas prisma and prisma_contract can no longer be a namespace of the project's contract. See prisma-tables-move-to-prisma-schema, name-the-prisma-schema, rename-a-namespace-named-prisma and marker-table-is-signatures in the app guide, and name-the-prisma-schema and prisma-tables-api-breaks in the extension guide. (#31234, #31287)

  • On SQLite, Prisma's own tables are prisma_signatures, prisma_config and prisma_ledger. They replace _prisma_marker and _prisma_ledger. The first command of this release that changes a database moves the rows, and from then on only this release may change it. See sqlite-prisma-tables-renamed in the app guide, and sqlite-prisma-tables-renamed and sqlite-prisma-tables-api-breaks in the extension guide. (#31317)

  • The contract marker is now the contract signature. prisma db verify --marker-only is --signature-only, nine error codes are renamed (six say SIGNATURE where they said MARKER, MIGRATION.MARKER_MISMATCH and MIGRATION.MARKER_NOT_IN_HISTORY are one code, MIGRATION.SIGNATURE_NOT_IN_GRAPH, and MIGRATION.MARKER_CAS_FAILURE is MIGRATION.CONCURRENT_CHANGE), --json output says signature where it said marker, and the client option verifyMarker is verifyContractSignature. Published names that said Marker say Signature. A script in the guides makes the renames. See contract-signature-flag and the three entries after it in the app guide and the extension guide. (#31297)

  • The application lists the platform packages. The database packages and the extensions now name @prisma/orm-framework, the family, the target and @prisma/orm-toolchain as peer dependencies, so the application gets one copy of each. List them in package.json at the same version as the database package. Extension authors move every @prisma/orm-* package their shipped code uses to peerDependencies. See list-the-platform-packages in the app guide and prisma-packages-are-peer-dependencies in the extension guide. (#31204)

    "dependencies": {
      "@prisma/orm-postgres": "8.0.0-rc.26",
      "@prisma/orm-framework": "8.0.0-rc.26",
      "@prisma/orm-family-sql": "8.0.0-rc.26",
      "@prisma/orm-target-postgres": "8.0.0-rc.26",
      "@prisma/orm-toolchain": "8.0.0-rc.26"
    }
  • The config imports definePrismaConfig from prisma/config. prisma orm init no longer adds @prisma/cli-engine to a project, so the config is made by the engine the prisma command runs. Change the import, and remove the @prisma/cli-engine line unless the project's own code imports it. See config-imports-prisma-config in the app guide. (#31253)

  • The packages publish only the import paths their users need. The database packages no longer forward the platform packages' paths that no application imports, and the platform packages stop publishing 57 paths that nothing outside them imports, and publish one more under a new name (utils/internal-error is utils/invariant-error). Published names that said "internal" have new names, such as InternalError, now InvariantError. Two scripts in the guides rewrite the imports, and list what they cannot change. Extension authors: the parts of postgres() that the Supabase extension reuses are now Early Access names, such as ea_connectWithBinding from @prisma/orm-postgres/runtime. See facade-paths-an-application-uses and platform-paths-an-extension-uses in the app guide and the extension guide, and postgres-client-parts-early-access-names in the extension guide. (#31256, #31276, #31241)

  • Stored files carry a format version. A contract.json and each migration snapshot have "formatVersion": 1 where they had "schemaVersion": "1", and every migration.json and ref file starts with "formatVersion": 1. This release still reads a migration.json or ref file without it, and changes nothing on disk. 8.0.0 refuses a file without it, so run the stored-files-format-version script from the guides before you upgrade to 8.0.0. See stored-files-format-version in the app guide and the extension guide. (#31200)

  • A fragment for any model is made on the client. db.orm.fragment(fields, body) is now db.fragment(fields, body), and tx.orm.fragment(...) is tx.fragment(...). db.orm holds only the contract's namespaces or models, so one may be named fragment. See fragment-on-the-client in the app guide and the extension guide. (#31259)

    Before:

    const summary = db.orm.fragment(fields, body);

    After:

    const summary = db.fragment(fields, body);
  • Sets of values that may grow say so in their types. Error codes, activity kinds, column defaults, migration statements, PostGIS geometries and the other sets that a later 8.x release may add a value to gain a catch-all member, (string & {}) or a member whose kind is FutureCase. A switch that checks every value with never needs a default branch; assign the value there to FutureCase to keep the compiler's check of the values you know. From 8.0.0, this is what lets a later 8.x release add a value without breaking a build. See app-middleware-handles-later-activities, app-switches-over-later-values and app-geometry-may-gain-types in the app guide, and extension-middleware-handles-later-activities, extension-switches-over-later-values and extension-more-open-sets-of-values in the extension guide. (#31246, #31257, #31293, #31304)

    Before:

    default: {
      const unreachable: never = columnDefault.kind;
    }

    After:

    default: {
      const later: FutureCase = columnDefault.kind;
      throw new Error(`Unknown column default ${String(later)}`);
    }
  • fns comparisons on a model field take the field's input type. In an ORM callback, fns.eq(p.status, 'NOT_A_MEMBER') and the other seven fns comparisons no longer compile when the value is not of the field's type, as p.status.eq(...) already did not. Such a condition matched different rows than its author may have meant, so the guide has an agent report it rather than edit it. See orm-fns-comparison-takes-field-input-type in the app guide and the extension guide. (#31299)

  • updateAll and updateAndCount take no explicit type argument. They now have two type parameters, because they also take a callback, so a call that passes one, such as drafts.updateAll<typeof drafts>({ ... }) on const drafts = db.orm.public.Post.where({ draft: true }), no longer compiles. Remove the type argument; TypeScript infers both. See update-all-explicit-type-argument in the app guide and the extension guide. (#31299)

  • In the SQL builder, a column name that several joined tables share needs its table. With three or more joined tables, such a name, such as f.id, is no longer a top-level field. In 8.0.0-rc.25 it type-checked and silently read the last joined table that has the name, so check results that code produced. The string forms, such as select('id'), now throw ORM.COLUMN_AMBIGUOUS. See sql-builder-shared-join-column-name-needs-table in the app guide. (#31150)

  • Code generic over a prepared declaration handles a list parameter. ParamSpec, the type of each parameter in a prepared declaration, gains many?: { elementNullable: boolean }. Code that wraps prepare, prepareQuery or delegatingRuntime, or implements PrepareMember or DelegatingRuntime, and treats every parameter as one value may no longer type-check. See prepared-declaration-param-spec-can-be-a-list in the app guide and the extension guide. (#31318)

  • In the PostgreSQL SQL builder, a list column is typed as a list. A String[] or other scalar list column is refused where one value goes. An ordered comparison of it, such as fns.gt(f.tags, ['b']), is written in raw SQL. A list column on the left of fns.in is written as fns.or(fns.eq(…), fns.eq(…)), and on the left of fns.notIn as fns.and(fns.ne(…), fns.ne(…)). A raw expression in a list column's place is declared as a list: .returns({ codecId: 'pg/text@1', many: { elementNullable: false } }). fns.eq and fns.ne still compare a list column with an array. See sql-builder-list-column-in-a-one-value-position in the app guide. (#31318)

  • A client created without log prints to the console. Warnings go to console.warn, errors to console.error and info events to console.info; debug events are still dropped. To keep the console silent, pass log: { info() {}, warn() {}, error() {} }. mongo() now takes log too. See default-logger-console in the app guide. (#31244)

  • A contract signature that cannot be read only warns. On its first use of the database, the runtime no longer rejects a query with CONTRACT.SIGNATURE_READ_FAILED or CONTRACT.SIGNATURE_ROW_CORRUPT. It logs one warning and runs the query. To stop a deploy on such a database, run prisma db verify. See runtime-signature-check-only-warns in the app guide. (#31198)

  • In CI, db init and db update no longer advance the db ref. They now follow the rule db migrate follows, and say so with MIGRATION.REF_NOT_ADVANCED_IN_CI. Pass --advance-ref db in a CI job that needs the ref, or the new --no-advance-ref to write none and silence the notice. A ref they cannot write is now a warning, and the command exits 0. See db-init-db-update-ref-rule in the app guide. (#31291)

  • On MongoDB, 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 rename the collection or field, or replace the value, without asking. A script that passed --delete for such a change now fails with CLI.CONSENT_UNUSED. Swaps, chains and takeovers of names are refused with MIGRATION.PLANNING_FAILED. See mongo-stored-name-change-is-a-rename and the entries after it in the app guide. (#31192)

  • A MongoDB contract refuses a field, relation or enum named __proto__. Such a name used to be left out of the contract, or out of the rows the client read, without an error. Rename it and move the values documents hold under it. A migration.ts that the previous release generated with a __proto__: key needs that key rewritten as ['__proto__']: before you run it again. See mongo-proto-field-and-relation-names-refused and migration-ts-proto-key-computed in the app guide. (#31185)

  • A contract argument is read the same way on every command. A path to a migration directory now works wherever its name does, and migration new --from takes what migration plan --from takes. Some error codes change for scripts that match on them: on migration new --from, a hash prefix needs six characters or more and an unknown reference is MIGRATION.REF_NOT_FOUND; @db and @contract where a command does not take them are MIGRATION.REF_WRONG_GRAMMAR. Programs that call the control API's contract resolvers, such as resolveContractRef, pass a new required migrationDirResolution. See contract-argument-one-parser and control-api-ref-resolution-takes-migration-dir in the app guide, and control-api-ref-resolution-takes-migration-dir in the extension guide. (#31288)

  • Each database package's contract-types entry exports types only. Importing a value from it, such as coreHash, compiled and then failed when it ran; it now fails to compile. Use import type for a type, and import a value from the package's contract/types or family-contract/types (family-contract on MongoDB). See contract-types-exports-types-only in the app guide and the extension guide. (#31266)

  • Extension authors: data types declare their parameter names, and validators are checked through Standard Schema. A data type with a parameter schema declares paramKeys, and DataType.params and an index type's options are typed as a Standard Schema, not arktype's Type, so a second copy of arktype can no longer skip the check. See data-type-param-keys and the entries after it, and index-type-options-standard-schema, in the extension guide. (#31314, #31261)

  • Extension authors: commands read a database's policies from its config. A family's control instance and the SQL and MongoDB control adapters gain readDatabaseConfig and databaseConfigLocation, and the policy helpers lose "marker" from their names. The MongoDB runner's checkedPolicies is policiesInForce. See read-the-database-config, policy-helpers-renamed and mongo-runner-checked-policies-renamed in the extension guide. (#31287, #31192)

  • Extension authors: targets use the framework's migration call interface. OpFactoryCall from @prisma/orm-target-mongo/target, MysqlOpFactoryCall and SqliteOpFactoryCall are gone; use OpFactoryCall from @prisma/orm-framework/components/control. See extension-migration-calls-use-framework-interface in the extension guide. (#31304)

Features

  • On PostgreSQL, a prepared statement takes a whole list as one parameter, declared with many, such as { ids: { codecId: 'pg/int8@1', many: { elementNullable: false } } }. In the SQL builder and the ORM, in then renders as = ANY($1::int8[]) and notIn as <> ALL($1::int8[]), so one statement serves a list of any length. A list parameter needs db.scalarList in the contract's required capabilities; without it, prepare fails with ORM.CAPABILITY_MISSING, and only PostgreSQL provides it. Raw SQL declares a list with .returns({ codecId, many: { elementNullable } }). (#31318)
  • @prisma/orm-better-auth lets Better Auth store its users and sessions through a Prisma 8 client, on PostgreSQL and SQLite: betterAuth({ database: prismaAdapter(db) }). Better Auth's auth generate adds the models and fields its plugins need to a Prisma schema. (#31176, #31187)
  • updateAll and updateAndCount take a callback, so an update can set a column from another column, an expression or raw SQL, such as incrementing a counter, without reading the row first. (#31299)
  • prisma migration ref policy set and the commands beside it change the policies a ref declares, so a ref file no longer has to be edited by hand. No error suggests changing a policy any more. (#31214)
  • A Prisma schema can use an index type an extension adds, such as a ParadeDB index: the SQL defineConfig passes the config's extensions to the schema reader. (#31258)
  • When the config has no database connection, the CLI's advice adds --db <url> to the database commands it suggests. (#31268)
  • From release 8.0, each package's version shows its maturity level, such as 8.3.0 for a Generally Available package and 8.3.0-ea.0 for an Early Access one. Release 8.0 is published as 8.0.1. (#31212)
  • Development builds are numbered as the upcoming release, such as 8.0.1-dev.3, so a range such as ^8.0.0-rc.25 no longer picks one up in place of a release. (#31251)
  • The upgrade skill looks up the version of the prisma CLI, and of Prisma packages published from other repositories, on npm, instead of assuming the ORM's version. (#31262)

Fixes

  • On PostgreSQL, a char(n) or bit(n) parameter that the adapter casts, such as each element of a list or a single value in a select list, is no longer cut to its first character: casts now use bpchar and varbit. 8.0.0-rc.25 had this defect, so a char(n)[] column written with it may hold values cut to one character, and a write of a bit(n)[] value failed with an error. Check the char(n)[] columns: see postgres-char-bit-list-values-check in the app guide. (#31318)
  • On PostgreSQL, a comparison whose operand is itself a condition is now grouped in parentheses. For example, fns.in(fns.notExists(subquery), [true, false]) rendered NOT EXISTS (…) IN ($1, $2), which PostgreSQL reads as NOT (EXISTS (…) IN ($1, $2)). That is always false, where the query meant a condition that is always true. Results such a query gave on 8.0.0-rc.25 may be wrong. (#31318)
  • commit() after a transaction was rolled back or committed rejects with RUNTIME.TRANSACTION_CLOSED and sends nothing, also when no timeout is set. (#31089)
  • On PostgreSQL and SQLite, deleteAll() and updateAll() with several .where() calls send one DELETE … RETURNING or UPDATE … RETURNING again, and a delete that must read first returns only the rows it deleted. Since 8.0.0-rc.24 they could return a row another connection changed or deleted between two statements. (#31188)
  • The PostgreSQL driver checks a pooled connection that has been idle for a second or more, and replaces it if it is dead, so a query no longer fails on a connection the server closed. (#31229)
  • db migrate picks the same one of several equally short routes on every machine, whatever its locale. (#31225)
  • db migrate plans a new database in milliseconds, where it ran out of memory when many data migrations provided invariants. (#31213)
  • Migration advice says to adopt a database that already has tables with db sign before db migrate, and says correctly whether a ref will move. (#31284)
  • On PostgreSQL, a role that may not read Prisma's tables is told the grant it needs, not that the database is unsigned or has no migrations. (#31312)
  • Under pnpm, a project that builds type declarations for a contract builds again: the database packages export every type a contract's inferred type names, including the types an extension's index types and data types name. (#31260, #31283)
  • SQL contract builder errors no longer show the internal name __unbound__. (#31191)

Known problems

  • @prisma/orm-extension-paradedb has no release for 8.0.0-rc.26. It is no longer published from this repository, and moves to a repository of its own. Its 8.0.0-rc.25 release bundles migrations with the old hashes, and this release refuses to load an extension built for an earlier release. An application that uses it stays on 8.0.0-rc.25 until the extension publishes a release for this one. (#31251)

New contributors

Don't miss a new orm release

NewReleases is sending notifications on new releases.