Repository navigation
v8.0.0-rc.26
Pre-releasev8.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-inputsscript from the app guide, which rewrites every hash in the project's stored files, and runprisma contract emit. In that release's deploy, runprisma db sign --no-advance-refand thenprisma db migrateagainst 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 withMIGRATION.DESCRIPTOR_HEAD_HASH_MISMATCH. Seecontract-hash-inputsin 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 andconn.for the connection. Sosql.returningisdb.returning, andsql.interactiveTransactionsisconn.interactiveTransactions. This release refuses acontract.jsonor migration snapshot that still storescapabilities, withCONTRACT.VALIDATION_FAILED; thecontract-hash-inputsscript rewrites them. Code that reads a contract's capabilities changes too. Seecode-reads-required-capabilitiesandrequired-capabilities-as-listin the app guide, andextension-code-reads-required-capabilitiesandrequired-capabilities-as-listin 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
postgres15topostgres18andpostgresDriver. Without it, the contract requires the newest version's list and the driver's, andprisma contract emitwarns withCONTRACT.REQUIRED_CAPABILITIES_NOT_LISTED; Prisma 8.0 requires the list. A config built with the coredefineConfiggets no default, so add the list before you emit.transaction()needsconn.interactiveTransactions, whichpostgresDriverlists.prisma db sign,db verify,db migrate,db updateanddb initnow 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. Seepostgres-contract-lists-required-capabilitiesand the entries after it in the app guide, andextension-contract-lists-required-capabilitiesand 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. Themarkertable is replaced byprisma.signatures, one row per contract space, andprisma.config, which holds the database's policies. The first command of this release that changes a database (db init,db update,db migrateordb 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 runsprismaagainst a database to this release at once. Grants, reset scripts and queries that nameprisma_contractor themarkertable name the new tables, and a role other than the one that ran the move needsSELECTonprisma.signatures, and onprisma.configwhere it runs Prisma's commands. The schemasprismaandprisma_contractcan no longer be a namespace of the project's contract. Seeprisma-tables-move-to-prisma-schema,name-the-prisma-schema,rename-a-namespace-named-prismaandmarker-table-is-signaturesin the app guide, andname-the-prisma-schemaandprisma-tables-api-breaksin the extension guide. (#31234, #31287) -
On SQLite, Prisma's own tables are
prisma_signatures,prisma_configandprisma_ledger. They replace_prisma_markerand_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. Seesqlite-prisma-tables-renamedin the app guide, andsqlite-prisma-tables-renamedandsqlite-prisma-tables-api-breaksin the extension guide. (#31317) -
The contract marker is now the contract signature.
prisma db verify --marker-onlyis--signature-only, nine error codes are renamed (six saySIGNATUREwhere they saidMARKER,MIGRATION.MARKER_MISMATCHandMIGRATION.MARKER_NOT_IN_HISTORYare one code,MIGRATION.SIGNATURE_NOT_IN_GRAPH, andMIGRATION.MARKER_CAS_FAILUREisMIGRATION.CONCURRENT_CHANGE),--jsonoutput sayssignaturewhere it saidmarker, and the client optionverifyMarkerisverifyContractSignature. Published names that saidMarkersaySignature. A script in the guides makes the renames. Seecontract-signature-flagand 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-toolchainas peer dependencies, so the application gets one copy of each. List them inpackage.jsonat the same version as the database package. Extension authors move every@prisma/orm-*package their shipped code uses topeerDependencies. Seelist-the-platform-packagesin the app guide andprisma-packages-are-peer-dependenciesin 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
definePrismaConfigfromprisma/config.prisma orm initno longer adds@prisma/cli-engineto a project, so the config is made by the engine theprismacommand runs. Change the import, and remove the@prisma/cli-engineline unless the project's own code imports it. Seeconfig-imports-prisma-configin 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-errorisutils/invariant-error). Published names that said "internal" have new names, such asInternalError, nowInvariantError. Two scripts in the guides rewrite the imports, and list what they cannot change. Extension authors: the parts ofpostgres()that the Supabase extension reuses are now Early Access names, such asea_connectWithBindingfrom@prisma/orm-postgres/runtime. Seefacade-paths-an-application-usesandplatform-paths-an-extension-usesin the app guide and the extension guide, andpostgres-client-parts-early-access-namesin the extension guide. (#31256, #31276, #31241) -
Stored files carry a format version. A
contract.jsonand each migration snapshot have"formatVersion": 1where they had"schemaVersion": "1", and everymigration.jsonand ref file starts with"formatVersion": 1. This release still reads amigration.jsonor ref file without it, and changes nothing on disk.8.0.0refuses a file without it, so run thestored-files-format-versionscript from the guides before you upgrade to8.0.0. Seestored-files-format-versionin the app guide and the extension guide. (#31200) -
A fragment for any model is made on the client.
db.orm.fragment(fields, body)is nowdb.fragment(fields, body), andtx.orm.fragment(...)istx.fragment(...).db.ormholds only the contract's namespaces or models, so one may be namedfragment. Seefragment-on-the-clientin 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 whosekindisFutureCase. Aswitchthat checks every value withneverneeds adefaultbranch; assign the value there toFutureCaseto keep the compiler's check of the values you know. From8.0.0, this is what lets a later 8.x release add a value without breaking a build. Seeapp-middleware-handles-later-activities,app-switches-over-later-valuesandapp-geometry-may-gain-typesin the app guide, andextension-middleware-handles-later-activities,extension-switches-over-later-valuesandextension-more-open-sets-of-valuesin 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)}`); }
-
fnscomparisons on a model field take the field's input type. In an ORM callback,fns.eq(p.status, 'NOT_A_MEMBER')and the other sevenfnscomparisons no longer compile when the value is not of the field's type, asp.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. Seeorm-fns-comparison-takes-field-input-typein the app guide and the extension guide. (#31299) -
updateAllandupdateAndCounttake no explicit type argument. They now have two type parameters, because they also take a callback, so a call that passes one, such asdrafts.updateAll<typeof drafts>({ ... })onconst drafts = db.orm.public.Post.where({ draft: true }), no longer compiles. Remove the type argument; TypeScript infers both. Seeupdate-all-explicit-type-argumentin 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 asselect('id'), now throwORM.COLUMN_AMBIGUOUS. Seesql-builder-shared-join-column-name-needs-tablein the app guide. (#31150) -
Code generic over a prepared declaration handles a list parameter.
ParamSpec, the type of each parameter in a prepared declaration, gainsmany?: { elementNullable: boolean }. Code that wrapsprepare,prepareQueryordelegatingRuntime, or implementsPrepareMemberorDelegatingRuntime, and treats every parameter as one value may no longer type-check. Seeprepared-declaration-param-spec-can-be-a-listin 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 asfns.gt(f.tags, ['b']), is written in raw SQL. A list column on the left offns.inis written asfns.or(fns.eq(…), fns.eq(…)), and on the left offns.notInasfns.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.eqandfns.nestill compare a list column with an array. Seesql-builder-list-column-in-a-one-value-positionin the app guide. (#31318) -
A client created without
logprints to the console. Warnings go toconsole.warn, errors toconsole.errorand info events toconsole.info; debug events are still dropped. To keep the console silent, passlog: { info() {}, warn() {}, error() {} }.mongo()now takeslogtoo. Seedefault-logger-consolein 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_FAILEDorCONTRACT.SIGNATURE_ROW_CORRUPT. It logs one warning and runs the query. To stop a deploy on such a database, runprisma db verify. Seeruntime-signature-check-only-warnsin the app guide. (#31198) -
In CI,
db initanddb updateno longer advance thedbref. They now follow the ruledb migratefollows, and say so withMIGRATION.REF_NOT_ADVANCED_IN_CI. Pass--advance-ref dbin a CI job that needs the ref, or the new--no-advance-refto write none and silence the notice. A ref they cannot write is now a warning, and the command exits 0. Seedb-init-db-update-ref-rulein 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,@mapor stored value changes,migration plananddb updaterename the collection or field, or replace the value, without asking. A script that passed--deletefor such a change now fails withCLI.CONSENT_UNUSED. Swaps, chains and takeovers of names are refused withMIGRATION.PLANNING_FAILED. Seemongo-stored-name-change-is-a-renameand 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. Amigration.tsthat the previous release generated with a__proto__:key needs that key rewritten as['__proto__']:before you run it again. Seemongo-proto-field-and-relation-names-refusedandmigration-ts-proto-key-computedin 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 --fromtakes whatmigration plan --fromtakes. Some error codes change for scripts that match on them: onmigration new --from, a hash prefix needs six characters or more and an unknown reference isMIGRATION.REF_NOT_FOUND;@dband@contractwhere a command does not take them areMIGRATION.REF_WRONG_GRAMMAR. Programs that call the control API's contract resolvers, such asresolveContractRef, pass a new requiredmigrationDirResolution. Seecontract-argument-one-parserandcontrol-api-ref-resolution-takes-migration-dirin the app guide, andcontrol-api-ref-resolution-takes-migration-dirin the extension guide. (#31288) -
Each database package's
contract-typesentry exports types only. Importing a value from it, such ascoreHash, compiled and then failed when it ran; it now fails to compile. Useimport typefor a type, and import a value from the package'scontract/typesorfamily-contract/types(family-contracton MongoDB). Seecontract-types-exports-types-onlyin 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, andDataType.paramsand an index type'soptionsare typed as a Standard Schema, not arktype'sType, so a second copy of arktype can no longer skip the check. Seedata-type-param-keysand the entries after it, andindex-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
readDatabaseConfiganddatabaseConfigLocation, and the policy helpers lose "marker" from their names. The MongoDB runner'scheckedPoliciesispoliciesInForce. Seeread-the-database-config,policy-helpers-renamedandmongo-runner-checked-policies-renamedin the extension guide. (#31287, #31192) -
Extension authors: targets use the framework's migration call interface.
OpFactoryCallfrom@prisma/orm-target-mongo/target,MysqlOpFactoryCallandSqliteOpFactoryCallare gone; useOpFactoryCallfrom@prisma/orm-framework/components/control. Seeextension-migration-calls-use-framework-interfacein 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,inthen renders as= ANY($1::int8[])andnotInas<> ALL($1::int8[]), so one statement serves a list of any length. A list parameter needsdb.scalarListin the contract's required capabilities; without it,preparefails withORM.CAPABILITY_MISSING, and only PostgreSQL provides it. Raw SQL declares a list with.returns({ codecId, many: { elementNullable } }). (#31318) @prisma/orm-better-authlets Better Auth store its users and sessions through a Prisma 8 client, on PostgreSQL and SQLite:betterAuth({ database: prismaAdapter(db) }). Better Auth'sauth generateadds the models and fields its plugins need to a Prisma schema. (#31176, #31187)updateAllandupdateAndCounttake 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 setand 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
defineConfigpasses 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.0for a Generally Available package and8.3.0-ea.0for an Early Access one. Release 8.0 is published as8.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.25no longer picks one up in place of a release. (#31251) - The upgrade skill looks up the version of the
prismaCLI, and of Prisma packages published from other repositories, on npm, instead of assuming the ORM's version. (#31262)
Fixes
- On PostgreSQL, a
char(n)orbit(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 usebpcharandvarbit. 8.0.0-rc.25 had this defect, so achar(n)[]column written with it may hold values cut to one character, and a write of abit(n)[]value failed with an error. Check thechar(n)[]columns: seepostgres-char-bit-list-values-checkin 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])renderedNOT EXISTS (…) IN ($1, $2), which PostgreSQL reads asNOT (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 withRUNTIME.TRANSACTION_CLOSEDand sends nothing, also when no timeout is set. (#31089)- On PostgreSQL and SQLite,
deleteAll()andupdateAll()with several.where()calls send oneDELETE … RETURNINGorUPDATE … RETURNINGagain, 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 migratepicks the same one of several equally short routes on every machine, whatever its locale. (#31225)db migrateplans 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 signbeforedb 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-paradedbhas 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)