@prisma/sdk
4.0.0 · 28 Jun 2022Apache-2.040.1k / weekRepositoryHomepagenpmAtom feed
2.30.3 is the newest release of 2.x.
In short
1 deprecated45 new
- Deprecated
We will at some point in the near future add a deprecation warning to the
prisma introspectCLI command.
Security
1 advisory affects 2.18.0; 2.20.0 fixes them
- HighCommand injection vulnerability in @prisma/sdk in getPackedPackage functionGHSA-pxcc-hj8w-fmm7 · 6 Apr 2021Fixed in 2.20.0
Release note
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.- Deprecated
We will at some point in the near future add a deprecation warning to the
prisma introspectCLI command. Eventually,
prisma introspectwill 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
$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
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
Improve handling of unexecutable migrations in Prisma Migrate
Migration Script Created With Foreign Key Fields in Wrong Order
Prisma Migrate - Drift detected error on each migrate run even when nothing changes in DB/Schema
Prisma Studio
Hiding a field, refreshing, then showing the field again is problematic
Feature request: Being able to select entries to download/export as JSON
Language tools (e.g. VS Code extension)
Prisma engines
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.
A whole project to check? Paste its package.json in the dependency check: every deprecated, outdated or vulnerable dependency, with what to upgrade to. Free, no account.