Alex Ruheni
4.0.0
prisma rainbow
Prisma 4.0.0
features a variety of improvements across Prisma Migrate, Prisma schema, and Prisma Client. These changes will impact most Prisma users, particularly those who used some of our most popular Preview features around advanced index management, raw SQL queries, and filtering rows by properties of JSON. As this is a major release, we included many breaking bug fixes and other enhancements, but we believe upgrading is worthwhile.
You can find a detailed guide in the Prisma 4 Upgrade guide.
Here’s a summary of the changes:
🦦 Preview features moved to General Availability:
• extendedIndexes
• filterJson
• improvedQueryRaw
🗃️ Default values for scalar lists
Prisma 4 now introduces support for defining default values for scalar lists (arrays) in the Prisma schema. You can define default scalar lists in your schema as follows:
model User {
id Int @id @default(autoincrement())
posts Post[]
favoriteColors String[] @default(["red", "blue", "green"])
}
Refer to our docs to learn more about this feature.
mongodb Improved default support for embedded documents
From version 4.0.0
, you can now define default values on embedded documents using the @default
attribute. Prisma will provide the specified default value on reads if a field is not defined in the database.
Refer to our upgrade guide for a detailed explanation and steps when working with default fields on composite types in MongoDB.
🪄 New Prisma Client APIs – findUniqueOrThrow
& findFirstOrThrow
We’re introducing two new APIs to Prisma Client:
• findUniqueOrThrow
– retrieves a single record as findUnique
but returns RecordNotFound
exception when no record is not found
• findFirstOrThrow
– retrieves the first record in a list as findFirst
but returns a RecordNotFound
exception when no record is found
The APIs will be convenient for scripts API routes where you’re already handling exceptions and want to fail fast.
🚀 Improvements and breaking changes
Here’s a list of more breaking changes and improvements we shipped:
• Deprecating rejectOnNotFound
• Fix rounding errors on big numbers in SQLite
• DbNull
, JsonNull
, and AnyNull
are now objects
• Prisma Studio updates
• Dropped support for Node 12
• New default sizes for statement cache
• Removal of undocumented support for the type
alias
• Removal of the sqlite
protocol for SQLite URLs
• Better grammar for string literals
• Explicit unique constraints for 1:1 relations
• Removed support for the usage of references
on implicit m:n relations
• Enforcing the uniqueness of referenced fields in the references
argument in 1:1 and 1:m relations for MySQL
• Renaming of @prisma/sdk
npm package to @prisma/internals
• Removal of the internal schema
property from the generated Prisma Client
📚 Learn more in the release notes
For more info and links to documentation, you can read the release notes.
🌟 Help us spread the word about Prisma 🌟
To help spread the word about Prisma, we’d very much appreciate if you would star the repo 🌟 And if you’re excited about the features in this week’s release, then help us and share your excitement on Twitter.
📰 Join us on Thursday for the “What’s new in Prisma” livestream
This week, @nikolasburk and @Sabin Adams will discuss the latest release and other news from the Prisma ecosystem in a this Thursday at 5 pm Berlin | 8 am San Francisco.