Today, we are excited to share the `2.29.0` stable release 🎉
🌟 **Help us spread the word about Prisma by starring the repo or [tweeting](https://twitter.com/intent/tweet?text=Check%20out%20the%20latest%20prisma%20release%20v2.29.0%20%F0%9F%9A%80%0D%0A%0D%0Ahttps://github.com/prisma/prisma/releases/tag/2.29.0) about the release.** 🌟
Major improvements & new features
Interactive Transactions are now in Preview
Today we’re introducing Interactive Transactions – one of our most debated [feature requests](https://github.com/prisma/prisma/issues/1844).
Interactive Transactions are a double-edged sword. While they allow you to ignore a class of errors that could otherwise occur with concurrent database access, they impose constraints on performance and scalability.
While we believe there are [better alternative approaches](https://www.prisma.io/blog/how-prisma-supports-transactions-x45s1d5l0ww1#transaction-patterns-and-better-alternatives), we certainly want to ensure people who absolutely need them have the option available.
You can opt-in to Interactive Transactions by setting the `interactiveTransactions` preview feature in your Prisma Schema:
prisma
generator client {
provider = "prisma-client-js"
previewFeatures = ["interactiveTransactions"]
}
Note that the interactive transactions API does not support controlling isolation levels or locking for now.
You can find out more about implementing use cases with transactions in [the docs](https://www.prisma.io/docs/concepts/components/prisma-client/transactions#interactive-transactions), and [share your feedback](https://github.com/prisma/prisma/issues/8664).
Named Constraints are now in Preview
Named Constraints allow you to represent (when using introspection) and specify (when using Prisma Migrate) the names of constraints of the underlying database schema in your Prisma schema.
Before this release, you could only specify the underlying database constraint names for [`unique`](https://www.prisma.io/docs/reference/api-reference/prisma-schema-reference#unique-1) and [`index`](https://www.prisma.io/docs/reference/api-reference/prisma-schema-reference#index). This meant that you didn't have control over all constraint names in the database schema. In projects that adopted Prisma with introspection, some constraint names from the database were not represented in the Prisma schema. This could lead to the database schema across environments getting out of sync when one environment was introspected, and another was created with Prisma Migrate and had different constraint names.
Starting with this release, you can specify the underlying database constraint names for [`id`](https://www.prisma.io/docs/reference/api-reference/prisma-schema-reference#id), `id`, `unique`, and `relation` constraints.
You can opt-in to Named Constraints by adding the `namedConstraints` preview feature to your Prisma Schema:
prisma
generator client {
provider = "prisma-client-js"
previewFeatures = ["namedConstraints"]
}
After enabling the `namedConstraints` preview flag, you can specify the names of constraints in the database schema using the `map` attribute:
- `id(map: "custom_primary_key_constraint_name")`
- `id([field1, field2], map: "custom_compound_primary_key_name")`
- `unique(map: "custom_unique_constraint_name")`
- `unique([field1, field2], map: "custom_compound_unique_constraint_name")`
- `index([field1, field2], map: "custom_index_name")`
- `relation(fields: [fieldId], references: [id], map: "custom_foreign_key_name")`
After specifying the `map` attribute, Prisma Migrate will use it when creating migrations.
When using `prisma db pull` with `namedConstraints`, these names will be automatically populated in your Prisma schema unless they match our default naming convention (which follows the Postgres convention). When handwriting a Prisma schema, these names are optional and will alternatively be filled with the default names by Prisma under the hood.
The `name` argument in `unique` and `id`
In addition to the `map` argument, the `unique` and the `id` attributes have the `name` argument (optional) that Prisma uses to generate the `WhereUnique` argument in the Prisma Client API.
> **Note:** You can use both `name` and `map` together, e.g. `unique([firstName, lastName], name: "NameOfWhereUniqueArg", map: "NameOfUniqueConstraintInDB")`
For example, given the following model:
prisma
model User {
firstName String
lastName String
id([firstName, lastName])
}
The following Prisma Client query is valid:
ts
const user = await prisma.user.findUnique({
where: {
// firstName_lastName is the default `name`
firstName_lastName: {
firstName: 'Ada',
lastName: 'Lovelace',
},
},
})
By adding the `name` argument to the `id` attribute:
diff
model User {
firstName String
lastName String
- id([firstName, lastName])
+ id([firstName, lastName], name: "fullname")
}
The following query is valid:
ts
const user = await prisma.user.findUnique({
where: {
// fullname comes from the name argument
fullname: {
firstName: 'Ada',
lastName: 'Lovelace',
},
},
})
Note: For the `unique` attribute this functionality was already available in previous releases. For `id` this is new.
---
You can learn more about `namedConstraints` in [our documentation](https://prisma.io/docs/concepts/components/prisma-schema/names-in-underlying-database).
Please check our [upgrade guide](https://prisma.io/docs/guides/upgrade-guides/upgrading-to-use-preview-features/enabling-named-constraints) before enabling the preview flag and running migrate operations for the first time. It explains what to do if you either want to keep the existing names in your database or want to switch to the default names for a cleaner Prisma schema.
Prisma Adopts Semantic Versioning (SemVer)
As previously announced, we are adjusting our release policy to adhere more strictly to [Semantic Versioning](https://semver.org/).
In the future, breaking changes in the stable development surface i.e. [General Availability](https://www.prisma.io/docs/about/releases#generally-available-ga) will only be rolled out with major version increments.
You can learn more about the change in the [announcement blog post](https://www.prisma.io/blog/prisma-adopts-semver-strictly).
Fixes and improvements
Prisma Client
- [API for interactive transactions with dependencies between write-operations](https://github.com/prisma/prisma/issues/1844)
- [[SQL Server] add validation for disallowed relationships (e.g. cyclic)](https://github.com/prisma/prisma/issues/4580)
- [The incoming request has too many parameters. The server supports a maximum of 2100 parameters. Reduce the number of parameters and resend the request.](https://github.com/prisma/prisma/issues/6693)
- [Transaction with bad input should rollback (when using middleware)](https://github.com/prisma/prisma/issues/6705)
- [PANIC in libs/prisma-models/src/record.rs:161:30 | Invalid coercion encountered: ConversionFailure("Bytes](https://github.com/prisma/prisma/issues/7097)
- [Unique constraint error inside a transaction throws unparsed error (but works fine when using Node API)](https://github.com/prisma/prisma/issues/7326)
- [No PrismaClientKnownRequestError if error in transaction](https://github.com/prisma/prisma/issues/7399)
- [No PrismaClientKnownRequestError when unique constraint fails in transaction](https://github.com/prisma/prisma/issues/7786)
- ["Mongo is not yet supported" in databaseTypeToConnectorType()](https://github.com/prisma/prisma/issues/8261)
- [Nested update with `updateMany` does not update the updatedAt timestamps for related records properly](https://github.com/prisma/prisma/issues/8265)
- [Enable Type Discovery](https://github.com/prisma/prisma/issues/8443)
Prisma Migrate
- [Failure creating a migration with MSSQL: `Introducing FOREIGN KEY constraint '...' on table '...' may cause cycles or multiple cascade paths. Specify ON DELETE NO ACTION or ON UPDATE NO ACTION, or modify other FOREIGN KEY constraints.`](https://github.com/prisma/prisma/issues/5782)
- [Migration checksum EOL-independent](https://github.com/prisma/prisma/issues/7101)
- [need to run db push twice in order to apply changes](https://github.com/prisma/prisma/issues/7411)
- [Modifying enum value in Postgres causes an error](https://github.com/prisma/prisma/issues/7712)
- [Investigate and remove usage of `--forceExit`](https://github.com/prisma/prisma/issues/7795)
- [Removing element from enum not working](https://github.com/prisma/prisma/issues/8137)
- [Error: Error in migration engine. Reason: [migration-engine/connectors/sql-migration-connector/src/sql_renderer/mssql_renderer.rs:394:9] not yet implemented: DROP TYPE [dbo].[syspolicy_target_filters_type] ](https://github.com/prisma/prisma/issues/8185)
- [Re-Introspection: `introspect --url` outputs additional lines which make output result unusable](https://github.com/prisma/prisma/issues/8321)
- [Check validity of having Unique Constraint and Primary Key Constraint on the same Column on SqlServer](https://github.com/prisma/prisma/issues/8463)
- [`config.datasources[0].provider` from GetConfig needs to be a string and not a string[]](https://github.com/prisma/prisma/issues/8467)
- [SQL Server: Unable to rename a column referenced by a relation](https://github.com/prisma/prisma/issues/8539)
- [Remove skipped SQL Server tests](https://github.com/prisma/prisma/issues/8544)
- [error: Error validating model "foo": The custom name `bar` specified for the `unique` attribute is already used as a name for a field. Please choose a different name.](https://github.com/prisma/prisma/issues/8576)
Credits
Huge thanks to benkenawell for helping!
📺 Join us for another "What's new in Prisma" livestream
Learn about the latest release and other news from the Prisma community by joining us for another ["What's new in Prisma"](https://www.youtube.com/watch?v=Dt9uEq1WVvQ) livestream.
The stream takes place [on Youtube](https://www.youtube.com/watch?v=Dt9uEq1WVvQ) on **Thursday, March 04** at **5pm Berlin | 8am San Francisco**.