Today we are excited to share the `2.6.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%202.6.0%20%F0%9F%9A%80%0D%0A%0D%0Ahttps://github.com/prisma/prisma/releases/tag/2.6.0) about the release.**
Major improvements
More robust introspection by keeping manual changes in the Prisma schema file
In prior releases, any manual changes to your Prisma schema would be overridden when invoking `prisma introspect` (e.g. usage of `map` or `map` as well as the renaming of relation fields).
Keeping these manual changes in the Prisma schema file has been available as a preview feature via the `--experimental-reintrospection` already. After getting tested as a preview feature for a few releases, we are excited to promote this functionality to be the default behavior of `prisma introspect` into this stable release.
Note that you can opt-out of this behavior by using the new `--force` flag: `prisma introspect --force`. This will generate a schema purely based on the introspected database and override any prior manual changes.
📚 **Documentation**: [Prisma Introspect](https://www.prisma.io/docs/reference/tools-and-interfaces/introspection)
Preview features
New: Atomic number operations on `update`
With today's release, we introduce atomic number operations for `update` queries in Prisma Client. It allows you to update the values of certain fields _atomically_.
Feature flag
Atomic number operations needs to be enabled with the feature flag `atomicNumberOperations` like so:
prisma
generator client {
provider = "prisma-client-js"
previewFeatures = ["atomicNumberOperations"]
}
Usage
We are introducing five atomic operations for `Int` and `Float` fields :
- `increment: x`: Adds `x` to the current value
- `decrement: x`: Subtracts `x` from the current value
- `multiply: x`: Multiplies the current value by `x`
- `divide: x`: Divides the current value by `x`
- `set: x`: Sets the value to `x` (equivalent to `data: { age: 18 }`)
> **Note**: Only one operation can be done per field at a time.
Here's an example of using the new operations:
ts
const result = await prisma.user.update({
where: {
email: 'helloworld.com',
},
data: {
points: {
set: 99, // this just sets the value, equivalent to `data: { points: 18 }`
},
age: {
increment: 1, // age = age + 1 - Happy Birthday!
},
credits: {
decrement: 2, // credits = credits - 2
},
karma: {
multiply: 3, // karma = karma * 3
},
chocolates: {
divide: 4, // chocolates = chocolates / 4
},
},
})
📚 **Documentation**: [Atomic operations on update](https://www.prisma.io/docs/reference/tools-and-interfaces/prisma-client/crud#atomic-operations-on-update)
Please [share your feedback](https://github.com/prisma/prisma/issues/3491) on how this feature works for you. We are interested in both positive and negative feedback, so we know if this feature is already ready for production! (If encounter any problems, please open a new issue [here](https://github.com/prisma/prisma/issues/new/choose)).
Already existing preview features from previous releases
Just a quick reminder:
- In version [`2.5.0`](https://github.com/prisma/prisma/releases/tag/2.5.0) we introduced one preview feature, namely `insensitiveFilters`.
- In version [`2.1.0`](https://github.com/prisma/prisma/releases/tag/2.1.0) we introduced two preview features, namely `connectOrCreate` and `transactionApi`.
In case they're useful for you, please give them a try and [share your feedback](https://github.com/prisma/prisma/issues/3108)! These features remain in preview in this release.
🤔 How would you describe Prisma?
We'd love to hear from you how you describe Prisma to your developer friends and coworkers. If you have 2 minutes, please answer this question via this [online form](https://prisma103696.typeform.com/to/icvIBKPv).
🌟 Help us spread the word about Prisma
To help spread the word about Prisma, we'd very much appreciate if you would **star this repo** 🌟 And if you're excited about the features in this week's release, then help us and [share it on Twitter](https://twitter.com/intent/tweet?text=Check%20out%20the%20latest%20Prisma%20release%202.6.0%20%F0%9F%9A%80%0D%0A%0D%0Ahttps://github.com/prisma/prisma/releases/tag/2.6.0).
Fixes and improvements
[`prisma`](https://github.com/prisma/prisma)
- [Rust Panic when querying a model with id](https://github.com/prisma/prisma/issues/1729)
- [Invalid `prisma/.env` leads to confusing error message](https://github.com/prisma/prisma/issues/1739)
- [[EPIC] Re-Introspection](https://github.com/prisma/prisma/issues/2829)
- [`prisma generate` stack overflow on a large schema](https://github.com/prisma/prisma/issues/3051)
- [[Re-Introspection] Comments in the schema are removed by re-introspection](https://github.com/prisma/prisma/issues/3052)
- [Self-referential one-to-many relationship query fails: "subquery has too many columns"](https://github.com/prisma/prisma/issues/3078)
- [Error in update with empty disconnect field](https://github.com/prisma/prisma/issues/3169)
- [Formatting Prisma 2 schema programmatically in JavaScript (file and string)](https://github.com/prisma/prisma/issues/3265)
- [Generating to a custom output path shows the wrong usage instructions](https://github.com/prisma/prisma/issues/3268)
- [Duplicate identifier 'Action' in `node_modules/.prisma/client/index.d.ts`](https://github.com/prisma/prisma/issues/3272)
- [Use error code for invalid schema.prisma for reintrospection and migrate](https://github.com/prisma/prisma/issues/3323)
- [Stabilize Re-Introspection and integrate it into normal `introspect`](https://github.com/prisma/prisma/issues/3331)
- [[Re-Introspection] Keep `updatedAt`](https://github.com/prisma/prisma/issues/3335)
- [List Relation Filter issue just in 2.5.0](https://github.com/prisma/prisma/issues/3342)
- [Filtering by null seems to be broken in 2.5](https://github.com/prisma/prisma/issues/3352)
- [JSON fields filtering stopped working in 2.5.0](https://github.com/prisma/prisma/issues/3364)
- [Add check of git commit during dowload tests ](https://github.com/prisma/prisma/issues/3415)
- [Aggregate ignores map value of field, generating an incorrect query](https://github.com/prisma/prisma/issues/3425)
- [Fix JSON autocompletion](https://github.com/prisma/prisma/issues/3441)
- [undici dependency cannot install - " Couldn't find match for "e76f6a37836537f08c2d9b7d8805d6ff21d1e744" git://github.com/mcollina/undici.git" - prisma/engine-core](https://github.com/prisma/prisma/issues/3472)
[`prisma-client-js`](https://github.com/prisma/prisma-client-js)
- [Hide top-level client properties (as they are visible via JS code intellisense)](https://github.com/prisma/prisma-client-js/issues/421)
- [Error when executing findMany query](https://github.com/prisma/prisma-client-js/issues/550)
- [Log event typing breaks when adding datasources to `PrismaClient` constructor](https://github.com/prisma/prisma-client-js/issues/801)
- [node script hanging after disconnect](https://github.com/prisma/prisma-client-js/issues/839)
- [New error after update to 2.5 for "not null" query](https://github.com/prisma/prisma-client-js/issues/842)
- [Implement step 1 of atomic operations on update ](https://github.com/prisma/prisma-client-js/issues/844)
[`migrate`](https://github.com/prisma/migrate)
- [Multiple failures for error report, error report is just validation error in the end](https://github.com/prisma/migrate/issues/535)
- [Report id 9877: ` Error querying the database: near ",": syntax error`](https://github.com/prisma/migrate/issues/543)
- [Running `save` outputs connection strings if included in schema file](https://github.com/prisma/migrate/issues/551)
- [schema validation errors should not trigger an error reporting](https://github.com/prisma/migrate/issues/571)
[`language-tools`](https://github.com/prisma/language-tools)
- [Document and Surface "Rename" functionality better](https://github.com/prisma/language-tools/issues/392)
- [Remove badges from VSCode Marketplace README](https://github.com/prisma/language-tools/issues/393)
- ["No result" when trying to rename model where it is used as type, not in model definition](https://github.com/prisma/language-tools/issues/394)
- [Enum default autocompletion support](https://github.com/prisma/language-tools/issues/404)
- [Detect VSCode theme and tell people to use a different one for better experience](https://github.com/prisma/language-tools/issues/405)
- [map gets initialized with `[]` instead of `""` when using autocompletion](https://github.com/prisma/language-tools/issues/429)
- [Option to stop extension from creating .vscode folder in workspace](https://github.com/prisma/language-tools/issues/439)
[`studio`](https://github.com/prisma/studio)
- [Opening relations in new tabs](https://github.com/prisma/studio/issues/9)
- [Relation "accordion" is closed when I click somewhere outside of the browser window](https://github.com/prisma/studio/issues/434)
- [Relation accordion does not indicate which items are/is connected](https://github.com/prisma/studio/issues/436)
- [Cmd+Click on a relation cell should open a new tab with appropriate filters applied to show only the connected records](https://github.com/prisma/studio/issues/474)
- [Opening the relations view is considered making a change](https://github.com/prisma/studio/issues/488)
- [Briefly displaying "No rows to shows" while loading is a bit confusing](https://github.com/prisma/studio/issues/489)
- [[feature] UX: click-through relations](https://github.com/prisma/studio/issues/499)
- [Info: The preview flags `middlewares` were removed, you can now safely remove them from your schema.prisma.](https://github.com/prisma/studio/issues/502)
- [Relation table is missing a min-height](https://github.com/prisma/studio/issues/506)
- [Error when trying to add a new record](https://github.com/prisma/studio/issues/508)
- [Blank screen when trying to filter a string field](https://github.com/prisma/studio/issues/510)
- [New Tab button (+) should always create a new tab](https://github.com/prisma/studio/issues/512)
- [Clicking a relation in relation table scrolls to the row in addition to selecting it](https://github.com/prisma/studio/issues/513)
- [New record disappears when navigating away (if there are no other records in the table)](https://github.com/prisma/studio/issues/514)
- [Visual feedback when adding new row if scrolled down](https://github.com/prisma/studio/issues/515)
- [Show fatal errors instead of White Screen of Death](https://github.com/prisma/studio/issues/516)
- [Update error message to say `prisma` not `prisma/cli`](https://github.com/prisma/studio/issues/517)
- [Relation table headers overlap if the model name is too long](https://github.com/prisma/studio/issues/518)
- [Some (not all) column type icons overlap the next column](https://github.com/prisma/studio/issues/519)
- [`skip` can be set to negative](https://github.com/prisma/studio/issues/521)
- [It isn't possible to delete uncommitted records](https://github.com/prisma/studio/issues/522)
- [Ugly scrollbar in relation editor](https://github.com/prisma/studio/issues/523)
- [Save [x] changes count not valid after creating a record](https://github.com/prisma/studio/issues/524)
- [Relation editor table should have a min-height](https://github.com/prisma/studio/issues/525)
- [Inconsistent state with no tabs](https://github.com/prisma/studio/issues/526)
- [Render a separator between uncommitted & committed records](https://github.com/prisma/studio/issues/527)
[`prisma-engines`](https://github.com/prisma/prisma-engines)
- [Datamodel Parser: Native Types](https://github.com/prisma/prisma-engines/issues/71)
- [Log what error caused a rollback in query engine](https://github.com/prisma/prisma-engines/issues/879)
- [Do not generate unnecessary db queries](https://github.com/prisma/prisma-engines/issues/969)
- [Adding optional relations on existing models on SQLite does not add a foreign key constraint](https://github.com/prisma/prisma-engines/issues/1022)
- [Multi-line alter tables on SQLite appear not to be working](https://github.com/prisma/prisma-engines/issues/1023)
- [Check that unique constraints can be added/removed from existing tables on MySQL](https://github.com/prisma/prisma-engines/issues/1027)
- [Check that column arity is preserved by AlterEnum on MySQL](https://github.com/prisma/prisma-engines/issues/1032)
- [Enum names must be validated that they are not using a reserved name](https://github.com/prisma/prisma-engines/issues/1052)
Credits
Huge thanks to peter50216 for helping!