Today, we are excited to share the 2.18.0
stable release 🎉
🌟 Help us spread the word about Prisma by starring the repo or tweeting about the release. 🌟
Major changes & improvements
prisma introspect
is becoming prisma db pull
In 2.10.0
we introduced the prisma db push
command that enables developers to update their database schema from a Prisma schema file without using migrations.
For the "opposite" motion (i.e., updating the Prisma schema from an existing database schema), we currently have the prisma introspect
command. In this release, prisma introspect
is being renamed to prisma db pull
. However, the prisma introspect
command will be kept around for a few more releases so that you have enough time to switch over to the new command.
Here is how we are planning to execute the renaming:
- In this release, we are introducing a new command
prisma db pull
, which behaves exactly the same asprisma introspect
. - We will at some point in the near future add a deprecation warning to the
prisma introspect
CLI command. - Eventually,
prisma introspect
will be removed.
There is no specific timeline to execute on this deprecation and we want to make sure we give developers a generous period of time to switch over.
Relation syntax will not be updated automatically any more
Prisma has a set of rules for defining relations between models in the Prisma schema.
The prisma format
command automatically helps to apply these rules by inserting missing pieces. As an example, consider this data model with an invalid relation:
model User {
id String @id
name String?
posts Post[]
}
model Post {
id String @id
authorId String?
author User? // not valid because the `@relation` attribute is missing
}
This example is not valid because the @relation
attribute is missing. Running npx prisma format
, automatically inserts the missing attribute:
model User {
id String @id
name String?
posts Post[]
}
model Post {
id String @id
authorId String?
+ author User? @relation(fields: [authorId], references: [id])
}
In previous releases, this expansion logic was applied automatically in several scenarios without running the formatter (by running npx prisma format
explicitly, or formatting via VS code), e.g. when running prisma migrate
. While helpful in some scenarios, these "magic" insertions often resulted in others errors that were harder to interpret and to debug for developers and ourselves.
In this release, the "magical" instertions are removed and developers need to explicitly run npx prisma format
if they want still make use of them.
More flexible seeding in TypeScript
The ts-node
command options can now be customized via package.json
to pass specific options to ts-node
. This makes prisma db seed
work with tools that have specific requirements when used with TypeScript, such as Next.js.
Here is an example that works with Next.js:
{
"name": "my-project",
"version": "1.0.0",
"scripts": {
"ts-node": "ts-node --compiler-options '{\"module\":\"CommonJS\"}'"
},
"devDependencies": {
"@types/node": "^14.14.21",
"ts-node": "^9.1.1",
"typescript": "^4.1.3"
}
}
New Upsert API for Prisma Client Go
Prisma Client Go now supports upsert operations:
post, _ := client.Post.UpsertOne(
// query
Post.ID.Equals("upsert"),
).Create(
// set these fields if document doesn't exist already
Post.Title.Set("title"),
Post.Views.Set(0),
Post.ID.Set("upsert"),
).Update(
// update these fields if document already exists
Post.Title.Set("new-title"),
Post.Views.Increment(1),
).Exec(ctx)
Learn more in the documentation and share your feedback in the #prisma-client-go
channel on Slack.
Fixes and improvements
Prisma Client
- Error connecting to GCP cloud sql using ssl connection
- Error opening a TLS connection: unknown Cert Authority
- Filter based on number / count of relations
- Issue with not closing DB connections
- Errors at nested writes
- Add update of non-existent node to known errors
- Handle illegal parameters in raw SQL queries gracefully
- Upsert not creating all entries
- uncheckedScalarInputs: XOR not working?
- Query produces
WHERE
clause with 1=0 as condition - User ID type instead of int to enable database transparency
- Internal: Send Slack message for each CLI release
- Improve on autogenerated bug report urls
- $transaction should fallback to union if it can't give unwrap a proper output
- Some exported types no longer available in Prisma namespace in 2.17
Prisma Migrate
- Error: [libs/datamodel/connectors/dml/src/datamodel.rs:175:14] Every RelationInfo should have a complementary RelationInfo on the opposite relation field.
- Empty index name:
ERROR: zero-length delimited identifier at or near """"
- Prisma Migrate: Better UX when referencing migrations in resolve command
- Introspection crash when relation name is only used on one side.
- Annotated relation field doesn't appear to be required for 1-n relations
- No validation error on 1:m ambiguous relation
- Improve handling of unexecutable migrations in Prisma Migrate
- Error: [libs/datamodel/connectors/dml/src/datamodel.rs:162:14] Every RelationInfo should have a complementary RelationInfo on the opposite relation field.
- Error using totvs database:
Couldn\'t parse default value
- Prisma format and issues with implicit relations
- Migration Script Created With Foreign Key Fields in Wrong Order
- Prisma seed incompatible with Nextjs et al. projects
- Prisma Migrate - Drift detected error on each migrate run even when nothing changes in DB/Schema
- When configuring
ShadowDatabaseUrl
to use Prisma Migrate in the cloud, a valid URL is always enforced across every environment, even though it's only needed in development. - Add
prisma db pull
command for introspection - ENUM in prisma migration
Prisma Studio
- Hiding a field, refreshing, then showing the field again is problematic
- Add ability to unlink optional relation
- Should be able to scroll filter column selection
- Unable to reset
DateTime
field tonull
- Feature request: Being able to select entries to download/export as JSON
- optional Int fields show NaN even if no values were entered
- Argument id for data.id must not be null
- Prisma Studio prevents saving changes when nullable values
- Unable to deselect all relations
Language tools (e.g. VS Code extension)
Prisma engines
- executeRaw does not work with updateMany mutation in transaction
- Migrate: catch soft reset errors in CLI
📝 Help us improve our release notes
We want to ensure our release notes are as helpful as possible for you! You can help us achieve this by taking part in the poll in this GitHub issue.
📺 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" livestream.
The stream takes place on Youtube on Thursday, March 04 at 5pm Berlin | 8am San Francisco.