nikolasburk
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:
1. In this release, we are introducing a new command prisma db pull
, which behaves exactly the same as prisma introspect
.
2. We will at some point in the near future add a deprecation warning to the prisma introspect
CLI command.
3. 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.
🌱 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"
}
}
⚠️ 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.
In previous releases, this expansion logic was applied automatically in several scenarios without running npx prisma format
explicitly, e.g. when running a prisma migrate
command. 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.
🆕 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)