Next-generation ORM for Node.js & TypeScript | PostgreSQL, MySQL, MariaDB, SQL Server, SQLite, MongoDB and CockroachDB
APACHE-2.0 License
Published by Jolg42 almost 3 years ago
Today, we are excited to share the 3.5.0
stable release 🎉
🌟 Help us spread the word about Prisma by starring the repo or tweeting about the release. 🌟
In 3.5.0
, we've added support for ordering full text search results by relevance. Ordering by relevance gives you a way to order search results by the best match. You can enable order by relevance and full-text search with the fullTextSearch
feature flag:
generator client {
provider = "prisma-client-js"
previewFeatures = ["fullTextSearch"]
}
datasource db {
provider = "postgresql"
url = env("DATABASE_URL")
}
model People {
id Int @id @default(autoincrement())
bio String
}
While this feature is useful standalone, it's most commonly used in combination with the full text search
field in the where
clause:
const query = "node.js developer"
const developers = await prisma.people.findMany({
where: {
bio: {
// Only select people whose bio's contain "node.js developer"
search: query,
},
},
orderBy: {
// Order that selection by query relevance.
_relevance: {
fields: ["bio"],
search: query,
sort: "desc",
},
},
})
Learn more in our documentation and if you run into any issues or have feedback for us, you can reach us in this issue.
We are extending the syntax in the Prisma schema to add support for configuration of length and sort order. This applies to:
These new configuration options come with full support for the prisma db pull
, prisma db push
and prisma migrate dev
commands, so index configuration can now be managed, evolved and deployed using Prisma's schema management tooling.
Two new arguments can now be specified per field:
length
(the maximum length of items in the index)sort
(how an index is sorted)In order to use these new capabilities, add the extendedIndexes
feature flag in the generator block:
generator client {
provider = "prisma-client-js"
previewFeatures = ["extendedIndexes"]
}
The change affects the @id
, @@id
, @unique
, @@unique
and @@index
fields in certain databases:
length
argument is available on MySQL on the @id
, @@id
, @unique
, @@unique
and @@index
fields. It allows Prisma to now support indexes and constraints on String
with a TEXT
native type and Bytes
types.sort
argument is available for all databases on the @unique
, @@unique
and @@index
fields. Additionally, SQL Server also allows it on @id
and @@id
.The following example demonstrates the use of the sort
and length
arguments:
model Post {
title String @db.VarChar(300)
abstract String @db.VarChar(3000)
slug String @db.VarChar(3000) @unique(sort: Desc, length: 42)
author String
created_at DateTime
@@id([title(length: 100, sort: Desc), abstract(length: 10)])
@@index([author, created_at(sort: Desc)])
}
⚠️ Warning: This might be a breaking change for some users. To learn how to mitigate that, please read the documentation linked below.
Learn more in the documentation on index configuration.
We've had this feature in the Prisma Client JS for awhile, but in this release, we've added case-insensitive query support to the Go Client as well. Now you can worry a bit less about what kind of data the user is going to send your way.
users, err := client.User.FindMany(
User.Email.Equals("prisMa"),
User.Email.Mode(QueryModeInsensitive), // sets case insensitivity
).Exec(ctx)
Learn more in our documentation.
uuid
is invalid_count
key of relation count is nullableengineType=binary
incompatible with Node.js v17?.env
are logged via DEBUG=*
db push
crashes on SQL Server because of Error: There is already an object named 'Post_authorId_fkey' in the database.
cockroachdb
provider in the Schema ParserengineType = "dataproxy"
or similarJoin us for the first Prisma Serverless Data Conference about all things databases and serverless. Here's an overview of the speakers at the conference:
In addition to these fantastic talks, you can look forward to the Prisma keynote with a lot of information about the current status and upcoming plans for the Prisma Data Platform.
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 Wednesday, November 17 at 5pm Berlin | 9am San Francisco.
Note: We usually stream on Thursdays, but this week we have moved the stream to Wednesday to leave space for the Serverless Data Conference on Thursday.
Published by janpio almost 3 years ago
Today, we are issuing the 3.4.2
patch release.
Published by Jolg42 almost 3 years ago
Today, we are issuing the 3.4.1
patch release.
Published by nikolasburk almost 3 years ago
Today, we are excited to share the 3.4.0
stable release 🎉
🌟 Help us spread the word about Prisma by starring the repo or tweeting about the release. 🌟
We are pleased to announce that Prisma version 3.4.0
provides support for PostgreSQL 14. For a full list of our supported databases and their versions, see our documentation.
In Prisma version 3.4.0
, we add support on MongoDB databases for using orderBy
with aggregate groups. This was previously available for relational databases.
For example, if the data about your application's users includes their city of residence, you can determine which cities have the largest user groups. The following query sorts each city
group by the number of users in that group, and returns the results in descending order (largest group first):
const groupBy = await prisma.user.groupBy({
by: ['city'],
_count: {
city: true,
},
orderBy: {
_count: {
city: 'desc',
},
},
})
For more information refer to our documentation about ordering by groups.
prisma db push
The prisma db push
command is used to sync your Prisma schema and your database schema in development.
Because MongoDB has a unique approach to database schema management, this initial release only syncs @unique
, @@unique
and @@index
annotations in your schema.
Let's look at a quick example using this Prisma schema:
datasource db {
provider = "mongodb"
url = env("DATABASE_URL")
}
generator js {
provider = "prisma-client-js"
previewFeatures = ["mongoDb"]
}
model BlogPost {
id String @id @default(dbgenerated()) @map("_id") @db.ObjectId
title String @unique
}
After running prisma db push
the CLI will display which changes were made:
Applying the following changes:
[+] Unique index `BlogPost_title_key` on ({"title":1})
Let's keep iterating on the schema. We apply the following changes:
title
author
and title
title
datasource db {
provider = "mongodb"
url = env("DATABASE_URL")
}
generator js {
provider = "prisma-client-js"
previewFeatures = ["mongoDb"]
}
model BlogPost {
id String @id @map("_id") @db.ObjectId
author String
title String
@@unique([author, title], map: "titleAuthorShouldBeUniqueUnique")
@@index([title])
}
and run prisma db push
again, we see what changes were applied:
Applying the following changes:
[-] Unique index `BlogPost_title_key`
[+] Index `BlogPost_title_idx` on ({"title":1})
[+] Unique index `titleAuthorShouldBeUniqueUnique` on ({"author":1,"title":1})
And voilà, the index and unique definitions in our schema are reflected in the database.
There is a known limitation with empty collections: if you db push
indexes or uniques on fields that do not have values in the collection (they are missing in all existing documents), and you use db pull
after that, the indexes and uniques will not be pulled because the fields will not be in your schema.
Since this is a Preview feature, any feedback is very much appreciated. Please get in touch by opening a GitHub issue.
For those interested in helping us getting introspection of embedded documents right, we packaged a first iteration into the CLI. More info in the Github issue.
Connection limit issues got you down? By using Prisma's Data Proxy, you can pool your connections to avoid overloading your database.
With this release, Prisma Client Go can now read and write to the Data Proxy.
You can generate a "Data Proxy"-enabled Go Client with the following command:
PRISMA_CLIENT_ENGINE_TYPE='dataproxy' go run github.com/prisma/prisma-client-go generate
Then you can use the Go Client as you normally would:
amas, err := client.Ama.FindMany().Exec(ctx)
if err != nil {
return err
}
for _, ama := range amas {
fmt.Println(ama.Status, ":", ama.Question)
}
// ANSWERED : How did you build this AMA page?
// ANSWERED : What is zero-cost type safety?
// UNANSWERED : What developer tools do you like?
Please note that the Data Proxy is currently in Early Access and still under active development. We do not recommend using the Data Proxy for production loads. If you run into any issues while trying to use the Go Client with the Data Proxy, please leave us a note in this issue.
We've had JSON filtering support in the TypeScript Client since . In 3.4.0, we're bringing support to the Go Client. Let's take a look at an example.
Given the following Prisma schema:
generator client {
provider = "prisma-client-go"
previewFeatures = ["filterJson"]
}
datasource db {
provider = "postgresql"
url = env("DATABASE_URL")
}
model Log {
id Int @id @default(autoincrement())
level Level
message String
meta Json
}
enum Level {
INFO
WARN
ERROR
}
You can now write the following to query a specific service name inside inside the meta
field:
logs, _ := client.Log.FindMany(
db.Log.Meta.Path([]string{"service"}),
db.Log.Meta.Equals(db.JSON("\"api\"")),
).Exec(ctx)
See some more examples of what you can do in our documentation. Note that the examples are written in Typescript, but the same concepts apply to Go as well!
orderByAggregateGroup
(since 2.21.0)Make sure to claim your ticket for our free Prisma Serverless Data Conference about all things databases and serverless with fantastic speakers from companies like PlanetScale, MongoDB, Vercel, Netlify, Cloudflare and CockroachDB.
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, November 04 at 5pm Berlin | 9am San Francisco.
Published by Jolg42 about 3 years ago
Today, we are excited to share the 3.3.0
stable release 🎉
🌟 Help us spread the word about Prisma by starring the repo or tweeting about the release. 🌟
In 3.3.0
, we're releasing Early Access support for Prisma Client connection pooling using Prisma Data Proxy. The Data Proxy feature of the Prisma Data Platform is now accessible to all users of the Prisma Data Platform (no need to request access).
Prisma Data Proxy is an intermediary between your app and your database. It manages connection pooling, so you can reliably use traditional databases in Serverless environments.
Users can configure a Data Proxy for free on the Prisma Data Platform and connect their Prisma applications to the proxy by enabling the feature flag for it in their code.
For detailed documentation and instructions please refer to pris.ly/data-proxy.
Using this new feature in Prisma Client and leveraging the Prisma Data Proxy, developers can now deploy Prisma applications on Cloudflare Workers. Here's what it looks like to use Prisma Client inside of this environment:
import { PrismaClient } from '@prisma/client'
const prisma = new PrismaClient()
addEventListener('fetch', (event) => {
event.respondWith(handleRequest(event.request))
})
async function handleRequest(request: Request): Promise<Response> {
await prisma.log.create({
data: {
level: 'Info',
message: `${request.method} ${request.url}`,
},
})
return new Response(`request method: ${request.method}!`)
}
Follow this deployment guide to learn how to use Prisma Client with your own Cloudflare Workers. If you run into any problems, you can reach us in this issue!
In 2.16.0
, we first introduced ordering by a relation for relational databases. As of today's release, you can now order by a relation field in MongoDB as well:
// Return a list of posts ordered by the author's email address
// in ascending order.
await prisma.post.findMany({
orderBy: {
author: {
email: "asc",
},
},
})
Learn more in our documentation.
Prisma now supports connecting to MongoDB 5 databases. Take advantage of the latest and greatest from the fine folks at MongoDB HQ!
When working with optional timestamp fields in MySQL, there were cases where the database implicitly set the column to NOT NULL
. To fix this behavior, we are now explicitly creating the columns as nullable.
You can find the full details about this change on GitHub.
With 3.3.0
, you can now filter and atomically update scalar lists with Prisma Client Go.
Given the following Prisma schema:
model User {
id Int @id @default(autoincrement())
name String
pets String[]
}
You can filter pets with the following code:
user, err := client.User.FindFirst(
db.User.Pets.HasSome([]string{"Fido", "Scooby"}),
).Exec(ctx)
And when you add a new furry addition to your family, you can update your list with Push
:
user, err := client.User.FindUnique(
db.User.Name.Equals(1),
).Update(
db.User.Items.Push([]string{"Charlemagne"}),
).Exec(ctx)
Learn more about how to use this new feature in our documentation. To dive deeper into the concept of scalar lists, you can read the guide on Working with scalar lists.
type
constructschema.prisma
from prisma init
)prisma migrate dev
exceeding 63 characters causing errors due to truncatingprisma init
init --url ...
logs full connection URL when .env already existsLearn about the latest release and other news from the Prisma community by joining us for another "What's new in Prisma" live stream.
The stream takes place on Youtube on Thursday, October 21 at 5pm Berlin | 8am San Francisco.
Huge thanks to @otan for helping!
Published by Jolg42 about 3 years ago
Today, we are issuing the 3.2.1
patch release.
Published by Jolg42 about 3 years ago
Today, we are excited to share the 3.2.0
stable release 🎉
🌟 Help us spread the word about Prisma by starring the repo or tweeting about the release. 🌟
In this version, we introduce support for introspecting MongoDB databases. If adding Prisma to an existing project, running prisma db pull
against a MongoDB database with existing data will sample the data and create a Prisma data model based on the stored documents.
This comes with a few caveats:
mongoDb
must be enabled on the generator
block in the Prisma schema.prisma db pull
multiple times will overwrite any manual changes to the data model for now.We're constantly iterating on this feature, so please provide feedback for introspecting MongoDB databases!
This release, we're giving MongoDB developers the ability to query the count of a relation. In the example below, we're getting the number of posts each user wrote:
const userWithPostsCount = await prisma.user.findMany({
include: {
_count: {
select: { posts: true },
},
},
})
// => [
// {
// email: "[email protected]",
// _count: { posts: 3 }
// }
// ]
This feature was previously available for SQL databases and now it's also available in MongoDB. Learn more in our documentation.
prisma db -h
still mentions seed
as a preview featureprisma init
Huge thanks to @otan, @cbuchacher for helping out in this release!
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, October 07 at 5pm Berlin | 8am San Francisco.
Published by Jolg42 about 3 years ago
Today, we are excited to share the 3.1.1
stable release 🎉
🌟 Help us spread the word about Prisma by starring the repo ☝️ or tweeting about the release.
Relational databases typically ensure integrity between relations with foreign key constraints, for example, given a 1:n relation between User:Post
, you can configure the deletion of a user to cascade to posts so that no posts are left pointing to a User that doesn't exist. In Prisma, these constraints are defined in the Prisma schema with the @relation()
attribute.
However, databases like PlanetScale do not support defining foreign keys. To work around this limitation so that you can use Prisma with PlanetScale, we're introducing a new referentialIntegrity
setting in Preview.
This was initially introduced in version 2.24.0
of Prisma with the planetScaleMode
preview feature and setting. Starting with this release both have been renamed to referentialIntegrity
.
The setting lets you control whether referential integrity is enforced by the database with foreign keys (default), or by Prisma, by setting referentialIntegrity = "prisma"
.
Setting Referential Integrity to prisma
has the following implications:
You can give it a try in version 3.1.1 by enabling the referentialIntegrity
preview flag:
datasource db {
provider = "mysql"
url = env("DATABASE_URL")
referentialIntegrity = "prisma"
}
generator client {
provider = "prisma-client-js"
previewFeatures = ["referentialIntegrity"]
}
After changing referentialIntegrity
to prisma
, make sure you run prisma generate
to ensure that the Prisma Client logic has been updated.
Note that Referential Integrity is set to prisma
by default when using MongoDB.
Learn more about it in our documentation, and share your feedback.
In an earlier release, we added Full-Text Search (for PostgreSQL) to the Typescript Client. This was released as a Preview feature.
In this release, we've added that Preview feature to the Go Client. Enable it in your Go project by adding the fullTextSearch
preview feature.
Here's an example:
// Fetch all drafts with a title that contains the words fox or dog
posts, _ := client.Post.FindMany(
db.Post.Title.Search("fox | dog"),
db.Post.Status.Equals("Draft"),
).Exec(context.Background())
// Loop over the posts and print the title
for _, post := range posts {
fmt.Println(post.Title)
}
You can get started with the Go Client using our Quick Start Guide. Learn more about Full-Text Search in our documentation.
Database connection management in serverless backends is challenging: taming the number of database connections, additional query latencies for setting up connections, etc.
At Prisma, we are working on a Prisma Data Proxy that makes integrating traditional relational and NoSQL databases in serverless Prisma-backed applications a breeze. If you are interested, you can sign up to get notified of our upcoming Early Access Program here:
https://pris.ly/prisma-data-proxy
Learn about the latest 3.1.1 release and other news from the Prisma community by joining Daniel Norman from the Prisma team for another What's new in Prisma livestream.
The stream takes place on Youtube on Thursday, September 23 at 5pm Berlin | 8am San Francisco.
planetScaleMode = true
is not preserved during db pull
Option::unwrap()
on a None
valuenApi
preview feature is still allowed and suggestedprisma 3.0.1
warns about breaking changes.onUpdate
with prisma level integrityHuge thanks to @saintmalik, @benkenawell, @ShubhankarKG, @hehex9 for helping!
Published by millsp about 3 years ago
Today, we are issuing the 3.0.2
patch release.
Published by Jolg42 about 3 years ago
Today, we are excited to share the 3.0.1
stable release 🎉
As previously announced, Prisma has adopted SemVer strictly and this is the first major release which means it has some breaking changes.
For all the breaking changes, there are guides and documentation to assist you with the upgrade.
This release promotes many Preview features to General Availability. This means that they are ready for production use and have passed rigorous testing both internally and by the community.
We recommend that you read through the breaking changes below carefully and make sure that you've correctly upgraded your application.
🌟 Help us spread the word about Prisma by starring the repo ☝️ or tweeting about the release.
Today's release is packed with many new features that are now Generally Available!
Here's a summary:
prisma db seed
has been revampedRead along to dive deeper into all the new Generally Available improvements.
To read more about what Generally Available means, check out the maturity levels in the Prisma docs.
Referential Actions is a feature that allows you to control how relations are handled when an entity with relations is changed or deleted. Typically this is done when defining the database schema using SQL.
Referential Actions allows you to define this behavior from the Prisma schema by passing in the onDelete
and onUpdate
arguments to the @relation
attribute.
For example:
model LitterBox {
id Int @id @default(autoincrement())
cats Cat[]
full Boolean @default(false)
}
model Cat {
id String @id @default(uuid())
boxId Int
box LitterBox @relation(fields: [boxId], references: [id], onDelete: Restrict)
}
Here, you would not be able to delete a LitterBox
as long as there still is a Cat
linked to it in your database, because of the onDelete: Restrict
annotation. If we had written onDelete: Cascade
, deleting a LitterBox
would also automatically delete the Cat
s linked to it.
Referential Actions was first released in in 2.26.0 with the referentialActions
Preview flag. Since then, we've worked to stabilize the feature.
Today, we're delighted to announce that Referential Actions is now General Available, meaning it is enabled by default. 🐱
On PostgreSQL, MySQL, SQLite and Microsoft SQL Server, referential actions will be enforced by the database.
If you use Prisma Migrate to manage your database schema, you can use introspection with prisma db pull
to automatically fill in the existing referential actions from your database. Please read the upgrade guide for all the details.
🚨 Please note that the defaults change in this release. In some cases, this can lead to queries behaving differently in Prisma 3.x compared to Prisma 2.x, since the database will be enforcing referential actions, and not Prisma Client anymore. This means that if you only update your client without changing your Prisma schema, you will lose Prisma-level protections against cascading deletes. Read more in the Breaking Changes section below and the upgrade guide for a detailed explanation and steps to follow. 🚨
One of the core concepts in Prisma is the Prisma schema which serves as a single source of truth for your database schema and application models. For Prisma to automatically generate migrations and Prisma Client, it's necessary for the Prisma schema to represent the database schema as accurately as possible.
Named Constraints allows the Prisma schema to more accurately represent the names of all currently supported constraints such as unique constraints, primary keys, etc.
By having this representation in the Prisma schema, you now have finer control over two things:
prisma db push
command.findUnique
queries on compound indices.Named Constraints was initially released in Preview in 2.29.0. Since then, we've made minor fixes and improvements to ease the upgrade experience.
Today, we're happy to launch Named Constraints to General Availability, meaning it will be enabled by default.
Named Constraints are about reflecting another aspect of the database in your Prisma schema: many objects in your schema, like indexes, unique constraints, and foreign keys, have a name in the database. That was not properly reflected in the Prisma Schema Language in earlier versions. The addition of Named Constraints fills this gap and improves overall correctness.
Given the following example:
model Post {
id Int @id(map: "pk_of_Post")
blog_id Int
blog Blog @relation(fields: [blog_id], references: [id], map: "Post_blog_fk")
title String
@@unique([title, blog_id], name: "Post_title_blog_id_unique", map: "Post.title_blog_id_unique")
}
model Blog {
id Int @id
posts Post[]
}
You can see that @id
, @relation
and @@unique
now can take a map
argument corresponding to the database name of the primary key/foreign key/constraint.
@@unique
can also take a name
argument to control the naming of the WhereUnique
argument in Prisma Client.
A quick way to remember: The new API is uniform. map: "..."
always corresponds to a name in the database, whereas name: "..."
always corresponds to names in the Prisma Client API.
🚨 Please note that you will have to make conscious decisions about constraint names when you upgrade to Prisma 3. Prisma will help you with the upgrade process using introspection with prisma db pull
and Prisma Migrate. Read more in the Breaking Changes section below and the upgrade guide for a detailed explanation and steps to follow. 🚨
Today we are excited to announce that Prisma support for Microsoft SQL Server and Azure SQL is Generally Available and ready for production!
Since we released Prisma Client for General Availability over a year ago with support for PostgreSQL, MySQL, SQLite, and MariaDB, we've heard from thousands of engineers about how the Prisma ORM is helping them be more productive and confident when building data-intensive applications.
After passing rigorous testing internally and by the community over the last year since the Preview release in version 2.10.0, we are thrilled to bring Prisma's streamlined developer experience and type safety to developers using Microsoft SQL Server and Azure SQL in General Availability 🚀.
Learn more in the release blog post 🤓
prisma db seed
has been revamped and is now Generally AvailableWhen developing locally, it's common to seed your database with initial data to test functionality. In version 2.15 of Prisma, we initially introduced a Preview version of seeding using the prisma db seed
command.
Today, we're excited to share that the prisma db seed
command has been revamped and simplified with a better developer experience and is now Generally Available.
The seeding functionality is now just a hook for any command defined in "prisma"."seed"
in your package.json
.
For example, here's how you would define a TypeScript seed script with ts-node
:
package.json
of your project// package.json
"prisma": {
"seed": "ts-node prisma/seed.ts"
}
import { PrismaClient } from '@prisma/client'
const prisma = new PrismaClient()
async function main() {
const alice = await prisma.user.upsert({
where: { email: '[email protected]' },
update: {},
create: {
email: '[email protected]',
name: 'Alice',
},
})
console.log({ alice })
}
main()
.catch((e) => {
console.error(e)
process.exit(1)
})
.finally(async () => {
await prisma.$disconnect()
})
This approach gives you more flexibility and makes fewer assumptions about how you choose to seed. You can define a seed script in any language as long as you it's just a terminal command.
For example, here's how you would seed using an SQL script and the psql
CLI tool.
// package.json
"prisma": {
"seed": "psql --dbname=mydb --file=./prisma/seed.sql"
}
🚨 Please note that if you already have a seed script that worked created in versions prior, you will need to add the script to prisma.seed
in your package.json
and adapt the script to the new API. Read more in the Breaking Changes section below and the seeding docs for a complete explanation and walkthroughs of common use cases.
Node-API is a new technique for binding Prisma's Rust-based query engine directly to Prisma Client. This reduces the communication overhead between the Node.js and Rust layers when resolving Prisma Client's database queries.
Earlier versions of Prisma (since version 2.0.0) used the Prisma Query Engine binary, which runs as a sidecar process alongside your application and handles the heavy lifting of executing queries from Prisma Client against your database.
In 2.20.0 we introduced a Preview feature, the Node-API library, as a more efficient way to communicate with the Prisma Engine binary. Using the Node-API library is functionally identical to running the Prisma engine binary while reducing the runtime overhead by making direct binary calls from Node.js.
Starting with today's 3.0.1 release we are making the Node-API library engine the default query engine type. If necessary for your project, you can fall back to the previous behavior of a sidecar Prisma Engine binary, however, we don't anticipate a reason to do so.
If you've been using this preview feature, you can remove the nApi
flag from previewFeatures
in your Prisma Schema.
Learn more about the Query Engine in our documentation.
Let's say you want to group your users by the city they live in and then order the results by the cities with the most users. Order by Aggregate Group allows you to do that, for example:
await prisma.user.groupBy({
by: ['city'],
_count: {
city: true,
},
orderBy: {
_count: {
city: 'desc',
},
},
}),
model User {
id Int @id @default(autoincrement())
email String @unique
city String
name String?
posts Post[]
}
model Post {
id Int @id @default(autoincrement())
title String
content String?
published Boolean @default(false)
author User? @relation(fields: [authorId], references: [id])
authorId Int?
}
Order by Aggregate Group was initially released as a Preview feature in 2.21.0.
Starting with today's release it is Generally Available 🤩
If you've been using this Preview feature, you can remove the orderByAggregateGroup
flag from previewFeatures
in your Prisma Schema.
Learn more about this feature in our documentation.
Ever wondered how you can query posts and have the results ordered by their author's name?
With Order by Relations, you can do this with the following query:
await prisma.post.findMany({
orderBy: {
author: {
name: 'asc',
},
},
include: {
author: true,
},
})
```tsx
model User {
id Int @id @default(autoincrement())
email String @unique
city String
name String?
posts Post[]
}
model Post {
id Int @id @default(autoincrement())
title String
content String?
published Boolean @default(false)
author User? @relation(fields: [authorId], references: [id])
authorId Int?
}
```
Order by Relation was initially released in Preview in 2.16.0.
Starting with today's 3.0.1 release it is Generally Available 🧙
If you've been using this preview feature, you can remove the orderByRelation
flag from previewFeatures
in your Prisma Schema.
Learn more about this feature in our documentation.
Select Relation Count allows you to count the number of related records by passing _count
to the select
or include
options and then specifying which relation counts should be included in the resulting objects via another select
.
Select Relation Count helps you query counts on related models, for example, counting the number of posts per user:
const users = await prisma.user.findMany({
include: {
_count: {
select: { posts: true },
},
},
})
If you've been using this Preview feature, you can remove the selectRelationCount
flag from previewFeatures
in your Prisma Schema.
Learn more about this feature in our documentation.
Some of the features above introduce breaking changes. In this section, we cover the breaking changes in more detail with links to upgrade guides in the documentation. We recommend that you read through the breaking changes carefully and make sure that you've upgraded and tested your application.
Starting with Prisma 3, the names of database constraints and indexes are reflected in the Prisma schema. This means that Introspection with db pull
as well as migrate
and db push
will work towards keeping your constraint and index names in sync between your schema and your database.
Additionally, a new convention for default constraint names is now built into the Prisma Schema Language logic. This ensures reasonable, consistent defaults for new greenfield projects. The new defaults are more consistent and friendlier to code generation. It also means that if you have an existing schema and/or database, you will either need to migrate the database to the new defaults, or introspect the existing names.
⚠️ This means you will have to make conscious choices about constraint names when you upgrade. Please read the Named Constraints upgrade guide for a detailed explanation and steps to follow. ⚠️
The default referential actions behaviors when you update or delete data changes between Prisma 2 and Prisma 3. This will lead to queries behaving differently in Prisma 3.x compared to Prisma 2.x.
In some cases, a delete operation will delete more data than previously. This is ****because in Prisma 2, cascading deletes and updates defined at the database level were prevented by Prisma Client, but will be allowed to happen in Prisma 3.
On relational databases, Prisma now relies on the database for referential actions — using db pull
after you upgrade will reflect the actual behavior in your Prisma Schema.
Please read the Referential Actions upgrade guide for a detailed explanation and steps to follow.
prisma db seed
, prisma migrate dev
, prisma migrate reset
The mechanism through which seeds are discovered changes. If you were already using seeding since Prisma 2.15.0, you will see a warning with steps to follow the next time seeding is triggered.
In summary, you will need to:
prisma.seed
in your package.json
See the example above in the Major Improvements section and read the seeding docs for a complete explanation.
⚠️ Please note that the breaking change applies if you have an existing seed file since Prisma 2.15.0 without using prisma db seed
. You will have to switch to the new mechanism. ⚠️
$queryRaw
API changesWe’ve taken this opportunity to cleanup $queryRaw
and $executeRaw
. In Prisma 2.x, the Prisma Client had different behavior depending on how you called $queryRaw
or $executeRaw
:
prisma.$queryRaw
...``. This API sent a prepared statement and was safe from SQL injections.prisma.$queryRaw(
...)
. This API sent a raw query string and was not safe from SQL injections.This was too subtle. Starting with Prisma 3, we've split our raw query APIs into "safe" and "unsafe":
$queryRaw
...``: Safe from SQL injections. Sends a prepared statement and returns the resulting rows.$executeRaw
...``: Safe from SQL injections. Sends a prepared statement and returns the result count.$queryRawUnsafe(
...)
: Not safe from SQL injections. Sends the query as a string and returns the resulting rows. Useful for queries that can't be prepared, like using a variable for the table name.$executeRawUnsafe(
...)
: Not safe from SQL injections. Sends the query as a string and returns the result count. Useful for queries that can't be prepared, like altering a column's data type.To update your application, you can do a "Find All" in your codebase for $queryRaw(
and $executeRaw(
. Then you can either turn them into tagged templates or use the unsafe functions.
While Filtering on a Json field was in Preview, we learned from a community member that you couldn't filter a Json field by the JSON value null.
This is because { equals: null }
checks if the value in the database is NULL
, not if the value inside the column is a JSON null
.
To fix this problem, we decided to split "null" on Json fields into JsonNull
, DbNull
and AnyNull:
Given the following model in your Prisma Schema:
model Log {
id Int @id
meta Json
}
Starting in 3.0.1, you'll see a TypeError if you try to filter by null
on a Json
field:
prisma.log.findMany({
where: {
data: {
meta: {
equals: null
// ^ TypeError: Type 'null' is not assignable to type
}
},
},
});
To fix this, you'll import and use one of the new null types:
import { Prisma } from '@prisma/client'
prisma.log.findMany({
where: {
data: {
meta: {
equals: Prisma.AnyNull,
},
},
},
})
This also applies to create, update and upsert. To insert a null
value into a Json field, you would write:
import { Prisma } from '@prisma/client'
prisma.log.create({
data: {
meta: Prisma.JsonNull,
},
})
And to insert a database NULL
into a Json field, you would write:
import { Prisma } from '@prisma/client'
prisma.log.create({
data: {
meta: Prisma.DbNull,
},
})
Learn more about JSON filtering in our documentation.
In 2.23.0, we announced that aggregate fields like count
will be deprecated in favor of the prefixed notation, i.e. _count
in order to avoid clashing with model fields names in your application.
For example:
const result = await prisma.user.groupBy({
by: ['name'],
- count: true,
+ _count: true,
})
In this release, we're removing the deprecated old notation. You now must prefix your aggregate fields with an underscore.
To help with this transition, we suggest searching your codebase for .aggregate({
and .groupBy({
, and prefixing count
, max
, min
, avg
and sum
are all prefixed with an underscore, i.e. _count
, _max
, _min
, _avg
, and _sum
.
You can learn more about the original deprecation in the 2.23.0 Release Notes.
Up until this release, Prisma supported versions 12.2 of Node.js and up
Starting with this release, the minimum required version of Node.js is 12.6.
microsoftSqlServer
preview flagdb seed
tests need to run on multiple platforms, not just UbuntureferentialActions
with Introspection and Migration CIreferentialActions
preview flagdb seed
feature$queryRaw
availability isn't derived from the DMMFnull
values on JSONB fieldsorderByRelations
orderByAggregateGroup
selectRelationCount
$queryRaw("...")
to throw for JS calls$queryRaw(...)
to $queryRawUnsafe(...)
NOT
within a NOT
creates a SQL query with only a single NOT
in 2.30.0count
should be _count
)array_starts_with
and array_ends_with
don't work on MariaDBHuge thanks to @saintmalik, @benkenawell, @ShubhankarKG, @hehex9 for helping!
Learn about the latest 3.0.1 release and other news from the Prisma community by joining Matt Muller and Daniel Norman from the Prisma team for another "What's new in Prisma" livestream.
The stream takes place on Youtube on Thursday, September 9 at 5pm Berlin | 8am San Francisco.
Published by Jolg42 about 3 years ago
Today, we are issuing the 2.30.3
patch release.
Published by millsp about 3 years ago
Today, we are issuing the 2.30.2
patch release.
Published by Jolg42 about 3 years ago
Today, we are excited to share the 2.30.0
stable release 🎉
🌟 Help us spread the word about Prisma by starring the repo or tweeting about the release. 🌟
We're excited to announce that Prisma Client now has preview support for Full-Text Search on PostgreSQL.
You can give this a whirl in 2.30.0 by enabling the fullTextSearch
preview flag:
datasource db {
provider = "postgresql"
url = env("DATABASE_URL")
}
generator client {
provider = "prisma-client-js"
previewFeatures = ["fullTextSearch"]
}
model Post {
id Int @id @default(autoincrement())
title String @unique
body String
status Status
}
enum Status {
Draft
Published
}
After you regenerate your client, you'll see a new search
field on your String
fields that you can query on. Here are a few examples:
// returns all posts that contain the words cat *or* dog.
const result = await prisma.post.findMany({
where: {
body: {
search: 'cat | dog',
},
},
})
// All drafts that contain the words cat *and* dog.
const result = await prisma.posts.findMany({
where: {
status: "Draft",
body: {
search: 'cat & dog',
},
},
})
You can learn more about how the query format works in our documentation. We would love to know your feedback! If you have any comments or run into any problems we're available in this in this Github issue.
Microsoft SQL Server has validation rules for your schema migrations that reject schema changes that introduce referential action cycles.
These scenarios tend to show up often for developers using the referentialActions
preview feature, which will become the default. The database error you get is not really helpful, so to provide a better experience, Prisma now checks for referential cycle actions when it validates your schema file and shows you the exact location of the cycle in your schema.
To learn more, check out the documentation.
prisma introspect
is being deprecated in favor of prisma db pull
👋🏻The prisma introspect
command is an alias for prisma db pull
so they are the same command. However, prisma db pull
is more intuitive since it pulls the schema from the database into your local schema.prisma
file. This naming also works as the counterpart of prisma db push
.
Starting with this release, you will get a warning that encourages you to use prisma db pull
instead of prisma introspect
.
As previously announced, we are adjusting our release policy to adhere more strictly to Semantic Versioning.
In the future, breaking changes in the stable development surface i.e. General Availability will only be rolled out with major version increments.
You can learn more about the change in the announcement blog post.
findUnique
$queryRaw
and $executeRaw
in 2.29.0.catch()
or .finally()
on a prisma client model query does not fire the request in 2.29.0Bytes
@id
columns with SQL Server@relation()
Huge thanks to @saintmalik for helping!
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, August 26 at 5pm Berlin | 8am San Francisco.
Published by Jolg42 about 3 years ago
Today, we are issuing the 2.29.1
patch release.
Published by millsp about 3 years ago
Today, we are excited to share the 2.29.0
stable release 🎉
🌟 Help us spread the word about Prisma by starring the repo or tweeting about the release. 🌟
Today we’re introducing Interactive Transactions – one of our most debated feature requests.
Interactive Transactions are a double-edged sword. While they allow you to ignore a class of errors that could otherwise occur with concurrent database access, they impose constraints on performance and scalability.
While we believe there are better alternative approaches, we certainly want to ensure people who absolutely need them have the option available.
You can opt-in to Interactive Transactions by setting the interactiveTransactions
preview feature in your Prisma Schema:
generator client {
provider = "prisma-client-js"
previewFeatures = ["interactiveTransactions"]
}
Note that the interactive transactions API does not support controlling isolation levels or locking for now.
You can find out more about implementing use cases with transactions in the docs, and share your feedback.
Named Constraints allow you to represent (when using introspection) and specify (when using Prisma Migrate) the names of constraints of the underlying database schema in your Prisma schema.
Before this release, you could only specify the underlying database constraint names for @@unique
and @@index
. This meant that you didn't have control over all constraint names in the database schema. In projects that adopted Prisma with introspection, some constraint names from the database were not represented in the Prisma schema. This could lead to the database schema across environments getting out of sync when one environment was introspected, and another was created with Prisma Migrate and had different constraint names.
Starting with this release, you can specify the underlying database constraint names for @id
, @@id
, @unique
, and @relation
constraints.
You can opt-in to Named Constraints by adding the namedConstraints
preview feature to your Prisma Schema:
generator client {
provider = "prisma-client-js"
previewFeatures = ["namedConstraints"]
}
After enabling the namedConstraints
preview flag, you can specify the names of constraints in the database schema using the map
attribute:
@id(map: "custom_primary_key_constraint_name")
@@id([field1, field2], map: "custom_compound_primary_key_name")
@unique(map: "custom_unique_constraint_name")
@@unique([field1, field2], map: "custom_compound_unique_constraint_name")
@@index([field1, field2], map: "custom_index_name")
@relation(fields: [fieldId], references: [id], map: "custom_foreign_key_name")
After specifying the map
attribute, Prisma Migrate will use it when creating migrations.
When using prisma db pull
with namedConstraints
, these names will be automatically populated in your Prisma schema unless they match our default naming convention (which follows the Postgres convention). When handwriting a Prisma schema, these names are optional and will alternatively be filled with the default names by Prisma under the hood.
name
argument in @@unique
and @@id
In addition to the map
argument, the @@unique
and the @@id
attributes have the name
argument (optional) that Prisma uses to generate the WhereUnique
argument in the Prisma Client API.
Note: You can use both
name
andmap
together, e.g.@@unique([firstName, lastName], name: "NameOfWhereUniqueArg", map: "NameOfUniqueConstraintInDB")
For example, given the following model:
model User {
firstName String
lastName String
@@id([firstName, lastName])
}
The following Prisma Client query is valid:
const user = await prisma.user.findUnique({
where: {
// firstName_lastName is the default `name`
firstName_lastName: {
firstName: 'Ada',
lastName: 'Lovelace',
},
},
})
By adding the name
argument to the @@id
attribute:
model User {
firstName String
lastName String
- @@id([firstName, lastName])
+ @@id([firstName, lastName], name: "fullname")
}
The following query is valid:
const user = await prisma.user.findUnique({
where: {
// fullname comes from the name argument
fullname: {
firstName: 'Ada',
lastName: 'Lovelace',
},
},
})
Note: For the @@unique
attribute this functionality was already available in previous releases. For @@id
this is new.
You can learn more about namedConstraints
in our documentation.
Please check our upgrade guide before enabling the preview flag and running migrate operations for the first time. It explains what to do if you either want to keep the existing names in your database or want to switch to the default names for a cleaner Prisma schema.
As previously announced, we are adjusting our release policy to adhere more strictly to Semantic Versioning.
In the future, breaking changes in the stable development surface i.e. General Availability will only be rolled out with major version increments.
You can learn more about the change in the announcement blog post.
updateMany
does not update the updatedAt timestamps for related records properlyIntroducing FOREIGN KEY constraint '...' on table '...' may cause cycles or multiple cascade paths. Specify ON DELETE NO ACTION or ON UPDATE NO ACTION, or modify other FOREIGN KEY constraints.
--forceExit
introspect --url
outputs additional lines which make output result unusableconfig.datasources[0].provider
from GetConfig needs to be a string and not a string[]bar
specified for the @@unique
attribute is already used as a name for a field. Please choose a different name.Huge thanks to @benkenawell for helping!
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.
Published by millsp about 3 years ago
Today, we are excited to share the 2.28.0
stable release 🎉
🌟 Help us spread the word about Prisma by starring the repo ☝️ or tweeting about the release. 🌟
Thanks to your feedback, we fixed a handful of bugs reported on the MongoDB connector (Preview):
findUnique
queries leading to an error #8276
Please keep reporting issues to our team and help to bring MongoDB support closer to GA!
We are adjusting our release policy to adhere more strictly to Semantic Versioning.
In the future, breaking changes in the stable development surface i.e. General Availability will only be rolled out with major version increments.
You can learn more about the change in the announcement blog post.
The latest release of the Prisma Data Platform enables you to create new Prisma projects and provision a database in under 3 minutes.
The Prisma Data Platform already allows you to:
The new onboarding flow makes it possible to get started with Prisma quickly for new Prisma projects! 🚀
When creating a new Prisma project, the Prisma Data Platform allows you to:
If you already have a Prisma project, you can continue to import it from GitHub and connect it to your database.
This whole process now takes less than 3 minutes to set up, so we’re looking forward to seeing how you will use this feature for your prototyping and production needs.
If you have any issues or questions, let us know by opening a GitHub issue.
If you have a Heroku account, we can create a free Postgres database for you:
Start your project with a schema from our templates:
Database connection management in serverless backends is challenging: taming the number of database connections, additional query latencies for setting up connections, etc.
At Prisma, we are working on a Prisma Data Proxy that makes integrating traditional relational and NoSQL databases in serverless Prisma-backed applications a breeze. If you are interested, you can sign up to get notified of our upcoming Early Access Program here:
https://pris.ly/prisma-data-proxy
"
.Huge thanks to @ShubhankarKG, @hehex9 for helping!
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, July 15 at 5pm Berlin | 8am San Francisco.
Published by millsp over 3 years ago
Today, we are excited to share the 2.27.0
stable release 🎉
🌟 Help us spread the word about Prisma by starring the repo ☝️ or tweeting about the release. 🌟
We're thrilled to announce that Prisma now has Preview support for MongoDB. Here's how to get started:
Inside your schema.prisma
file, you'll need to set the database provider to mongodb
. You'll also need to add mongoDb
to the previewFeatures
property in the generator
block:
// Set the database provider to "mongodb"
datasource db {
provider = "mongodb"
url = env("DATABASE_URL")
}
// We want to generate a Prisma Client
// Since mongodb is a preview feature, we need to enable it.
generator client {
provider = "prisma-client-js"
previewFeatures = ["mongoDb"]
}
// Create our Post model which will be mapped to a collection in the database.
// All posts have a required `title`, `slug` and `body` fields.
// The id attributes tell Prisma it's a primary key and to generate
// object ids by default when inserting posts.
model Post {
id String @id @default(dbgenerated()) @map("_id") @db.ObjectId
slug String @unique
title String
body String
}
Next, you'll need to add a database connection string to your .env
file. We recommend using MongoDB Atlas to spin up a MongoDB database for free. Set the DATABASE_URL
to the connection string you got from MongoDB Atlas, it should be similar to the following string:
DATABASE_URL="mongodb+srv://admin:<password>@cluster0.quvqo.mongodb.net/myFirstDatabase?retryWrites=true&w=majority"
❗️ Don't forget to include the username and password you set while creating the database in the connection string, otherwise you won't be able to connect to it.
Then you can run npx prisma generate
to generate a MongoDB-compatible Prisma Client. The Prisma Client API is the same for Mongo as it is for other supported relational databases (PostgreSQL, MySQL, SQLite and Microsoft SQL Server).
To test that everything works, you can run the following script:
import { PrismaClient } from "@prisma/client"
const prisma = new PrismaClient()
async function main() {
// Create the first post
await prisma.post.create({
data: {
title: "Prisma <3 MongoDB",
slug: "prisma-loves-mongodb",
body: "This is my first post. Isn't MongoDB + Prisma awesome?!",
},
})
// Log our posts showing nested structures
console.dir(posts, { depth: Infinity })
}
main()
.catch(console.error)
.finally(() => prisma.$disconnect())
You should see a new post created and added to your database! You can use Prisma Studio to view the record you just added by running npx prisma studio
.
This is just the tip of the iceberg. Learn more in our Getting Started Guide.
We would love to know your feedback! If you have any comments or run into any problems we're available in this issue. You can also browse existing issues that have the MongoDB label.
This one's for our Mac users. Prisma now runs natively on the new M1 chips. Best of all, there's nothing to configure, it just works. Enjoy the speed bump!
pnpm
do not play well togetherERROR 70100 (1317): foreign key constraints are not allowed, see https://code.openark.org/blog/mysql/the-problem-with-mysql-foreign-key-constraints-in-online-schema-changes
ERROR HY000 (1105): direct DDL is disabled
migrate dev
and PostGis Viewsprisma init
for datasource providers in Preview/EarlyAccessLearn 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, July 15 at 5pm Berlin | 8am San Francisco.
Published by Jolg42 over 3 years ago
Today, we are excited to share the 2.26.0
stable release 🎉
🌟 Help us spread the word about Prisma by starring the repo or tweeting about the release. 🌟
In this release we are introducing a new feature in Preview which enables fine-grained control over referential actions ON DELETE
and ON UPDATE
for the foreign keys supporting relations in Prisma models.
Until now, Prisma created a foreign key for each relation between Prisma models with the following defaults: ON DELETE CASCADE ON UPDATE CASCADE
. In addition, when invoking the delete()
or deleteAll()
methods, Prisma Client performs runtime checks and will prevent the deletion of records on required relations if there are related objects referencing it, effectively preventing the cascade delete behavior. When using raw SQL queries for deletion, Prisma Client won't perform any checks, and deleting a referenced object will effectively cause the deletion of the referencing objects.
Example:
model User {
id String @id
posts Post[]
}
model Post {
id String @id
authorId String
author User @relation(fields: [authorId])
}
prisma.user.delete(...)
and prisma.user.deleteAll()
will fail if the user has posts.
Using raw SQL, e.g. using $queryRaw()
to delete the user will trigger the deletion of its posts.
⚠️ Turning on this feature could, when using
delete()
anddeleteMany()
operations, delete more data than before under certain circumstances. Make sure you read down below to understand why and anticipate these changes.
The feature can be enabled by setting the preview feature flag referentialActions
in the generator
block of Prisma Client in your Prisma schema file:
generator client {
provider = "prisma-client-js"
previewFeatures = ["referentialActions"]
}
With the feature enabled, the behavior is now the following:
prisma db push
, and introspection will set these in the database schema, e.g. @relation(... onDelete: SetNull)
will set translate to ON DELETE SET NULL
on the corresponding foreign key. See Syntax section below.onDelete
or onUpdate
attributes in @relation
are not present, default values are used:
ON DELETE RESTRICT
(NO ACTION
on SQL Server) for required relationsON DELETE SET NULL
for optional relationsON UPDATE CASCADE
for all relations regardless if optional or required.prisma db push
, and introspection will rely on the syntax and default values above to keep the referential actions between Prisma schema and database schema in sync.delete()
or deleteAll()
methods. Deleting referenced objects will succeed or not depending on the underlying foreign keys of relations, e.g. by default deletion will be prevented by the database because it's set to ON DELETE RESTRICT
, but will succeed if set to ON DELETE CASCADE
.onDelete
or onUpdate
attributes in the Prisma schema, the next time the database is updated with Prisma Migrate or prisma db push
, the database schema will be updated to use the default values on all foreign keys, ON DELETE RESTRICT ON UPDATE CASCADE
(ON DELETE NO ACTION ON UPDATE CASCADE
on SQL Server).prisma db push
, the existing defaults are probably in place (ON DELETE CASCADE ON UPDATE CASCADE
), and this could lead to deletion of records in conditions where a deletion was previously prevented by Prisma Client until the foreign key constraints are updated.The semantics of onDelete
and onUpdate
are almost exactly how SQL expresses ON UPDATE
and ON DELETE
. For the example below:
User
) of a Post
is deleted (onDelete
), delete all Post
rows that are referencing the deleted User
(Cascade
).id
field of the related User
is updated, also update authorId
of all Post
s that reference that User
.model User {
id String @id
posts Post[]
}
model Post {
id String @id
authorId String
author User @relation(fields: [authorId], onDelete: Cascade, onUpdate: Cascade)
}
Possible keywords for onDelete
and onUpdate
are: Cascade
, Restrict
(except SQL Server), NoAction
, SetNull
, SetDefault
.
If you run into any questions or have any feedback, we're available in this issue.
SetNull
on a required relation will lead to database errors when deleting referenced records because the non-nullable constraint would be violated.prisma init
now accepts a --datasource-provider
argumentThe prisma init
command now accepts a --datasource-provider
argument that lets you configure the default provider
for the initially generated datasource
block in your Prisma schema. The possible values for this argument are equivalent to the allowed values for the provider
field on datasource
blocks:
postgresql
(default)mysql
sqlite
sqlserver
(Preview, needs the microsoftSqlServer
preview feature flag)Here's an example that shows how to configure the initial Prisma schema skeleton with a SQLite database:
npx prisma init --datasource-provider sqlite
The Prisma Client currently communicates to Prisma's Query Engine over either HTTP or Unix domain sockets. After some experimentation, we realized we can improve this communication overhead by using Node-API, which provides direct memory access across processes.
We've been working the last couple of weeks to get ready to make Node-API the default way we communicate with the Query Engine. To prepare for this change, we fixed a bunch of bugs and we'd love for you to give it another try:
generator client {
provider = "prisma-client-js"
previewFeatures = ["nApi"]
}
Right now we're still compiling benchmarks, but you should see a nice speed boost by opting into Node-API. You can reach us in this issue if you run into anything!
join
raw query helper with SQL Servergenerate
gives TypeError [ERR_INVALID_ARG_TYPE]: The "path" argument must be of type string. Received an instance of Object
or TypeError: outputDir.endsWith is not a function
error and no helpful outputQuery engine exited with code 101 - thread 'main' panicked at 'Could not open datamodel file "/schema.prisma"...'
Engine is not yet connected.
CI test with Node-APIonDelete CASCADE
, this should be configurable.Introducing FOREIGN KEY constraint '...' on table '...' may cause cycles or multiple cascade paths. Specify ON DELETE NO ACTION or ON UPDATE NO ACTION, or modify other FOREIGN KEY constraints.
binaryTargets: env("..")
inside generator client
sectionHuge thanks to @B2o5T for helping!
Prisma Day is a two-day event of talks and workshops by members of the Prisma community, on modern application development and databases. It's taking place June 29-30th and is entirely online.
We look forward to seeing you there!
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, July 01 at 5pm Berlin | 8am San Francisco.
Published by Jolg42 over 3 years ago
Today, we are excited to share the 2.25.0
stable release 🎉
🌟 Help us spread the word about Prisma by starring the repo or tweeting about the release. 🌟
prisma migrate dev
Database schema drift occurs when your database schema is out of sync with your migration history, i.e. the database schema has drifted away from the source of truth.
With this release, we improve the way how the drift is printed to the console when detected in the prisma migrate dev
command. While this is the only command that uses this notation in today's release, we plan to use it in other places where it would be useful for debugging in the future.
Here is an example of how the drift is presented with the new format:
[*] Changed the `Color` enum
[+] Added variant `TRANSPARENT`
[-] Removed variant `RED`
[*] Changed the `Cat` table
[-] Removed column `color`
[+] Added column `vaccinated`
[*] Changed the `Dog` table
[-] Dropped the primary key on columns (id)
[-] Removed column `name`
[+] Added column `weight`
[*] Altered column `isGoodDog` (arity changed from Nullable to Required, default changed from `None` to `Some(Value(Boolean(true)))`)
[+] Added unique index on columns (weight)
.env
files in Prisma Client GoYou can now use a .env
file with Prisma Client Go. This makes it easier to keep database credentials outside your Prisma schema and potentially work with multiple clients at the same time:
example/
├── .env
├── main.go
└── schema.prisma
Learn more about using the .env
file in our documentation.
Node.js v10 reached End of Life on April 30th 2021. Many of our dependencies have already dropped support for Node.js v10 so staying up-to-date requires us to drop Node.js v10, too.
We recommend upgrading to Node.js v14 or greater for long-term support. You can learn more about Node.js releases on this page.
createMany
errors with: PANIC in query-engine/connectors/sql-query-connector/src/database/operations/write.rs:95:60called
Result::unwrap()on an
Err value: ScalarFieldNotFound { name: "updated_at", model: "FundMangerTeamMemberExperience" }
params
in Middleware testsprisma generate
doesn't install prisma client 2.24.xOption::unwrap()
on a None
value db push
/ migrate
is hiding the binary download process during generate
, leading to confusionshadowDatabaseUrl
from schemaHuge thanks to @82600417, @SuryaElavazhagan, @psavan1655 for helping!
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, June 17 at 5pm Berlin | 8am San Francisco.
Save the date for Prisma Day 2021 and join us for two days of talks and workshops by the most exciting members of the Prisma community.
We look forward to seeing you there!
Published by Jolg42 over 3 years ago
Today, we are issuing the 2.24.1
patch release.