Prisma

Latest version: v0.15.0

Safety actively analyzes 714772 Python packages for vulnerabilities to keep your Python projects secure.

Scan your dependencies

Page 20 of 44

2.17.0

Today, we are excited to share the `2.17.0` stable release 🎉

🌟 **Help us spread the word about Prisma by starring the repo or [tweeting](https://twitter.com/intent/tweet?text=Check%20out%20the%20latest%20Prisma%20release%202.17.0%20%F0%9F%9A%80%0D%0A%0D%0Ahttps://github.com/prisma/prisma/releases/tag/2.17.0) about the release.** 🌟 

Overview

- Native types are now stable
- Prisma Migrate now works with cloud-hosted databases (e.g. Heroku)
- Soft resets for cloud-hosted environments
- More improvements and bug fixes for Prisma Migrate
- Improvements and changes for `prisma db push`
- `prisma db seed` now supports custom schema locations
- Improvements and bug fixes in Prisma Client

Note that this release comes with some breaking changes. Read the **Breaking changes** section below to learn more.

Major improvements & new features

Native types are now stable

The `nativeTypes` preview feature flag has first been introduced in [`2.10.0`](https://github.com/prisma/prisma/releases/tag/2.11.0). Thanks to your continuous and awesome [feedback](https://github.com/prisma/prisma/issues/4045) for this feature, we're now able to release usage of native database types in the Prisma schema for General Availability 🎉

Note that this release comes with a few minor breaking changes compared to previous versions. Please read about the **Breaking Changes** below.

If you haven't followed previous releases, expand below to learn more about everything that's now possible with the new native types.

<details><summary>Expand to learn more about the benefits of native types</summary>

Rich column type mapping for Prisma types

Each Prisma type can now map to one of multiple native database types. Native database type attributes are:

- Specific to the underlying provider - for example, PostgreSQL uses **`db.Boolean`** for **`Boolean`** whereas MySQL uses **`db.TinyInt`**
- Written in PascalCase (for example, **`VarChar`** or **`Text`**)
- Prefixed by **`db`**, where **`db`** is the name of the **`datasource`** block in your Prisma schema

Type attributes give you:

- Exact control over **what native type [Prisma Migrate](https://www.prisma.io/docs/concepts/components/prisma-migrate/) creates in the database** - for example, a **`String`** can be **`db.VarChar(200)`** or **`db.Char(50)`**
- An **enriched schema** when you introspect - you can see if **`String`** is **`varchar(200)`** or just **`text`**.

To learn more about all the possible native type attributes, check out the [type mapping reference in the docs](https://www.prisma.io/docs/concepts/components/preview-features/native-types/native-types-mappings).

Extending Prisma schema beyond supported column types

Column types which are not (yet?) supported by Prisma Migrate can be used with Prisma Migrate and introspection through the Prisma type `Unsupported` which was introduced in Preview in the [last release]((https://github.com/prisma/prisma/releases/tag/2.16.0)):

prisma
model User {
id Int id default(autoincrement())
email String unique
name String? default("")
multilinestringField Unsupported("multilinestring") unique
}


`dbgenerated()` in the `default` directive can now take a String argument that enables developers to reflect database-level `DEFAULT` constraints not yet supported by Prisma Migrate. These default values will be surfaced when introspecting with `prisma introspect` and created/changed when using Prisma Migrate.

Developers can now add `ignore` and `ignore` attributes to models and fields, for fields they want to manage via Prisma Migrate but not surfaced in Prisma Client. These attributes are added by Prisma when introspecting entities which are not supported, e.g. a table with no unique column. They are now also kept in the Prisma schema when re-introspecting a database.

</details>

Prisma Migrate now works with cloud-hosted databases (e.g. Heroku)

Before this release, Prisma Migrate could be used to apply migrations in a cloud-hosted environment (CI/CD pipeline, manual deployment to production, staging, etc.), but it was impossible to create new migrations, due to the [requirement of a shadow database](https://www.prisma.io/docs/concepts/components/prisma-migrate#shadow-database). Prisma Migrate expects to have privileges to create the shadow database using the same credentials, but cloud providers generally do not allow creating logical databases.

Starting from this release, `prisma migrate dev` can now be used in development with cloud-hosted databases by configuring a separate connection URL for the shadow database.

To develop natively in the cloud with Prisma Migrate, developers can create two cloud-hosted databases, one being the development- and the other being the shadow-database.

The connection URI for the shadow database can be configured in the `datasource` block of the Prisma schema file, similarly to the datasource URL, by defining a `shadowDatabaseUrl` variable:

prisma
datasource db {
provider = "postgresql"
url = env("DATABASE_URL")
shadowDatabaseUrl = env("SHADOW_DATABASE_URL")
}


Soft resets for cloud-hosted environments

Another common limitation of cloud-hosted environments is that the database cannot be dropped and re-created using `DROP DATABASE` and `CREATE DATABASE`, due to insufficient privileges. Prisma Migrate so far relied on these statements to ensure the database is empty when it needs to be reset.

Database resets in the context of Prisma Migrate now gracefully fall back to dropping constraints, indexes and tables, if there are insufficient privileges to reset the database using `DROP DATABASE`.

Note that this comes with the caveat that there could be other entities in the database, which Prisma Migrate could fail to clean up.

More improvements and bug fixes for Prisma Migrate

- Prisma Migrate has now a built-in locking functionality to prevent multiple migrations from running concurrently.
- Ensure the Prisma schema is valid before prompting developers to reset the database.
- Better error message when using `migrate dev` - if a non-interactive environment is detected, you'll be suggested to use `prisma migrate deploy` instead.
- Improved error handling when Prisma Migrate finds empty migration directories, e.g. `prisma/migrations/20210119114009_init` (missing `migration.sql` file).
- In some occasions, when dealing with invalid schemas, e.g., duplicate constraint names, a panic in the Migration Engine would be triggered. These errors are now surfaced as validation errors instead.
- In certain cases, when dealing with UUID columns, Prisma Migrate would drop and re-create the columns every time a migration was generated. This has now been fixed.

Improvements and changes for `prisma db push`

- `prisma db push` now handles unexecutable migrations better, offering a path forward by resetting the database. For example, adding a new required field without a default value when there are rows in the table is considered an unexecutable migration; in such situations you will be prompted to first reset the database.
- Changes to command options:
- The flag `—-force` has been renamed to `--accept-data-loss` to be more explicit - this is required for certain changes that involve losing data, e.g. dropping a table or dropping a column if there are rows.
- We've added a new flag `—-force-reset` which first resets the database and then updates the schema - this can be useful to start from scratch and as a way to deal with unexecutable migrations (see above).

`prisma db seed` now supports custom schema locations

You can now point the `prisma db seed` command to a custom schema location using either of two approaches:

- Use the `--schema` option when running the command
- Define a default schema location in your `package.json` which will be picked up every time you run the command.

Improvements and bug fixes in Prisma Client

- **Transaction rollback fix**: We fixed an issue where if there was an error within the Prisma Client's runtime validation, the transaction wouldn't rollback. Learn more in this [issue](https://github.com/prisma/prisma/issues/5616).
- **SQL Server `server_name` fix**: Before we couldn't connect to certain kind of SQL Server instances. If the server was a managed instance from Azure, connecting to it with Prisma would return `Server name cannot be determined`. Additionally, when running a shared Azure SQL database, if the firewall setting was set to `redirect` (the default setting), our connection would first fail with advising the user to connect to a new server, and when changing the connection string regarding the error, the new connection would fail with the same error `Server name cannot be determined`. This is now fixed. Azure managed instances just work, as do redirections (which are done under the hood, automatically).
- **Native type fix for SQL Server**: Our native type validations limits were set too low. We'd consider the maximum of 2000 for `NVarChar`/`NChar` length and a maximum of 4000 for `VarChar`/`Char`/`VarBinary`/`Binary` length. The actual maximums are `4000` for first and `8000` for the latter types.
- **PostgreSQL numeric type fix**: In certain cases, when using `executeRaw` to insert number values to a `numeric` type in PostgreSQL, sometimes the stored value would be zero instead of the user input. An example value of `12345.0` is converted by JavaScript as an integer of 12345, which then is written as an integer to the table. The table column being numeric, the integer representation would always be zero in these cases. Now we should be able to convert integers to `numeric` without any trouble.

Bug fixes in Prisma Studio

- Studio can now display fields that are of type `Byte` and `BigInt`.
- Usage of the `createMany` preview feature doesn't crash Studio any more

Breaking changes

Type mapping from Prisma schema to the database for `Float` has changed from `Decimal` to `Double` in MySQL and PostgreSQL

Overview

If you use the `Float` scalar type in your Prisma schema and used Prisma Migrate to create the database schema in previous Prisam versions, the corresponding database column has the type `DECIMAL(65,30)`.

For example, given the following Prisma schema:

prisma
model Post {
id Int id default(autoincrement())
title String
content String?
reward Float // Previously mapped to DECIMAL(65,30). From 2.17.0 will map to Double
published Boolean default(false)
}


Previous version of Prisma Migrate would generate the following migration:

sql
-- CreateTable
CREATE TABLE "Post" (
"id" SERIAL NOT NULL,
"title" TEXT NOT NULL,
"content" TEXT,
"reward" DECIMAL(65,30) NOT NULL, //
"published" BOOLEAN NOT NULL DEFAULT false,
PRIMARY KEY ("id")
);


As of `2.17.0`, the remapping of the `Float` type from `Decimal(65,30)` to `Double` will cause Migrate to attempt to alter the database type of the `reward` column to `Double` the next time you create a migration.

What does this mean for users?

Nothing changes in Prisma Client until the next time you want to make a change to your schema. In that case, you'll need to decide if you want to keep using the `Decimal(65,30)` type in the database:

- If you want to continue using `Decimal(65,30)`, you need to change the type in the Prisma schema from `Float` to `Decimal`. Alternatively, you can also run `prisma introspect` which will automatically remap the previous `Float` fields to `Decimal`. Note that this will also change the type that Prisma Client returns from `Number` to `Decimal.js`.
- If you would like to change the column's type in the database from `Decimal(65,30)` to `Double`, leave the Prisma schema as is and create a new migration. Prisma Migrate will alter the column's type to `Double`. Note that if you have rows with data for the column, they will be cast from `Decimal(65,30)` to `Double`.

Check out this [video guide](https://www.youtube.com/watch?v=OsuGP_xNHco), which covers how to upgrade and address the remapping of Float.

Breaking changes due to strict type diffing and native types

Overview

Prisma has [default mappings](https://www.prisma.io/docs/concepts/components/preview-features/native-types/native-types-mappings) between each scalar type in the Prisma schema to the underlying database type. For example, the `String` scalar type in Prisma schema is mapped to a `TEXT` column on PostgreSQL by default.

Before this release, Prisma supported using a range of database column types for a given Prisma scalar. For example, define a field in Prisma schema as `String` and use `VARCHAR(50)` as the column type in the database using the `db.varchar(50)` type annotation .

With the introduction of native types in General Availability, you can now specify your desired database type for columns in the Prisma schema via the `db.DB_TYPE` field attributes, e.g., `db.varchar(50)`.

Because the `db.DB_TYPE` attribute now exists, Prisma no longer allows the loose mapping of Prisma scalar types to database column types without the specific notation. The only exception to this rule is when you want to use default mapping, e.g., the `String` Prisma scalar will map to `TEXT` on PostgreSQL.

Before

Given the following table in PostgreSQL:

sql
-- CreateTable
CREATE TABLE "User" (
"id" SERIAL NOT NULL,
"nickName" VARCHAR(50),
"name" TEXT NOT NULL,

PRIMARY KEY ("id")
);


Prisma would introspect the table as follows:

prisma
model User {
id Int id default(autoincrement())
nickName String? //defaults to TEXT on PostgreSQL but works with varchar
name String //defaults to TEXT on PostgreSQL but works with varchar
}


After

Because `VARCHAR(50)` can be expressed in native type notation. The matching Prisma schema for the `User` database table above on PostgreSQL is the following:

prisma
// Example for PostgreSQL

model User {
id Int id default(autoincrement())
nickName String? db.VarChar(50) // Prisma expects the column to be varchar and Prisma Migrate will change it if not
name String // Prisma expects the column to be of type TEXT (default for String) and Prisma Migrate will change it if not
}


What does this mean for users?

Moving forward, if you want specific database column types, which are supported by Prisma, you should make sure to use the native type notation for the corresponding fields in the Prisma schema.

For users of Prisma Migrate with existing databases, you must understand that Prisma Migrate will try to migrate every column of a type different than what's defined in the schema.

If we go back to the previous example with loose type mapping, with this Prisma schema:

prisma
model User {
id Int id default(autoincrement())
nickName String? //defaults to TEXT on PostgreSQL but works with varchar
name String //defaults to TEXT on PostgreSQL but works with varchar
}


and this initial database schema:

sql
-- CreateTable
CREATE TABLE "User" (
"id" SERIAL NOT NULL,
"nickName" VARCHAR(50),
"name" TEXT NOT NULL,

PRIMARY KEY ("id")
);


On PostgreSQL, from this release on, Prisma will the columns for the fields `nickName` and name to be of type `TEXT` and will generate a migration to alter the type of the `nickName` column:

sql
-- AlterTable
ALTER TABLE "User" ALTER COLUMN "nickName" SET DATA TYPE TEXT;


To avoid unnecessary migrations to change types you may have defined on purpose, you can run introspection once, which will add the native annotations to any fields when they do not match the default mappings by Prisma.

For the initial database schema we used in the example

sql
-- CreateTable
CREATE TABLE "User" (
"id" SERIAL NOT NULL,
"nickName" VARCHAR(50),
"name" TEXT NOT NULL,

PRIMARY KEY ("id")
);


This would be the resulting Prisma schema after running prisma introspect

sql
model User {
id Int id default(autoincrement())
nickName String? db.VarChar(50)
name String
}


Fixes and improvements

Prisma Client

- [postgresql column type date error](https://github.com/prisma/prisma/issues/1541)
- [Fixed-size column types as part of identifiers do not work on MySQL](https://github.com/prisma/prisma/issues/1778)
- [Query engine panics when the ID used to create a record and the actual ID in the database are different](https://github.com/prisma/prisma/issues/2687)
- [[Native Types] Ensure that fields of unsupported types aren't dropped](https://github.com/prisma/prisma/issues/3673)
- [Concurrent updates that don't interfere with each other](https://github.com/prisma/prisma/issues/4224)
- [[MySQL] Throw a better error message when connection is rejected due to self signed ssl certificate](https://github.com/prisma/prisma/issues/4605)
- [$executeRaw throws PostgreSQL ERROR: invalid scale in external "numeric" value or inserts 0.0](https://github.com/prisma/prisma/issues/4828)
- [Change parameter type of prisma.$transaction](https://github.com/prisma/prisma/issues/4949)
- [Weird required array typing](https://github.com/prisma/prisma/issues/4964)
- [Passing null to a string some filter crashes the engine](https://github.com/prisma/prisma/issues/5067)
- [PANIC: index out of bounds: the len is 1 but the index is 1](https://github.com/prisma/prisma/issues/5095)
- [Request URL is too long](https://github.com/prisma/prisma/issues/5126)
- [findFirst with `undefined` value shouldn't return data](https://github.com/prisma/prisma/issues/5149)
- [Prisma not combining queries for GraphQL server, leading to N+1 issues](https://github.com/prisma/prisma/issues/5274)
- [Inconsistent PascalCasing for DMMF type names](https://github.com/prisma/prisma/issues/5302)
- [map not carried over to `makeEnum`](https://github.com/prisma/prisma/issues/5383)
- [ignore and ignore support in the client](https://github.com/prisma/prisma/issues/5442)
- [Stabilize `nativeTypes`](https://github.com/prisma/prisma/issues/5444)
- [Prisma can not connect to `localhost` for MySQL, MariaDB and SQL Server (mostly when running those via Docker)](https://github.com/prisma/prisma/issues/5499)
- [Invalid client generation when use model named "Record"](https://github.com/prisma/prisma/issues/5500)
- [Negative number cannot be entered as string to Decimal input](https://github.com/prisma/prisma/issues/5508)
- [prisma/client version 2.16.x spams [dotnev][DEBUG] logs](https://github.com/prisma/prisma/issues/5562)
- [Add `PRISMA_DISABLE_WARNINGS`](https://github.com/prisma/prisma/issues/5587)
- [$transaction doesn't rollback in case any transaction fails](https://github.com/prisma/prisma/issues/5616)
- [Prisma client looks in root directory (C:\) for engine binary when used with Next.js](https://github.com/prisma/prisma/issues/5082)
- [UUID values are not automatically converted to their binary form on write on mysql and sqlite](https://github.com/prisma/prisma/issues/1776)
- [2.8.0 and above: MySQL, 'tinyint unsigned' field considered as 'boolean'](https://github.com/prisma/prisma/issues/3916)

Prisma Migrate

- [Ignoring table during introspection](https://github.com/prisma/prisma/issues/4510)
- [Prisma Migrate cannot reset the database when the user has insufficient privileges - this makes Prisma Migrate incompatible with some hosted cloud providers](https://github.com/prisma/prisma/issues/4803)
- [Error when migration directory exists but migration script is missing](https://github.com/prisma/prisma/issues/5170)
- [Error: Error in migration engine. Reason: [libs/datamodel/core/src/transform/ast_to_dml/validate.rs:226:34] called `Option::unwrap()` on a `None` value ](https://github.com/prisma/prisma/issues/5171)
- [Schema notation to not surface specific models in the Prisma Client API](https://github.com/prisma/prisma/issues/5217)
- [Migrate creates unnecessary migrations](https://github.com/prisma/prisma/issues/5244)
- [Migrate renames my indexes & throws Drift detected error even when nothing changes in DB/Schema](https://github.com/prisma/prisma/issues/5282)
- [Argument M is out of range for Native type NVarChar(4000) of SQL Server](https://github.com/prisma/prisma/issues/5287)
- [`ALTER TYPE` enum migrations fail in PostgreSQL](https://github.com/prisma/prisma/issues/5290)
- [prisma migrate dev: schema validation happens late in the process ](https://github.com/prisma/prisma/issues/5321)
- [Implement ignore on the field level](https://github.com/prisma/prisma/issues/5330)
- [Keep ignore and ignore during Re-Introspection](https://github.com/prisma/prisma/issues/5331)
- [Preserve `ignore`and `ignore` on re-introspection](https://github.com/prisma/prisma/issues/5395)
- [Migrate: Postgres connection string without port prints `undefined`](https://github.com/prisma/prisma/issues/5429)
- [`db seed` not documented in help output for `prisma db --help` ](https://github.com/prisma/prisma/issues/5431)
- [DB seed does not work with custom schema location from package.json](https://github.com/prisma/prisma/issues/5483)
- [Mention `prisma migrate deploy` in `migrate dev` non interactive error message for better discoverability.](https://github.com/prisma/prisma/issues/5531)
- [`prisma migrate dev --create-only`- if there are data loss warnings, the CLI prompts suggest the new migration will be applied when it is (rightfully)not ](https://github.com/prisma/prisma/issues/5605)

Language tools

- [Ensure `ignore` code completion is supported in VS code extension](https://github.com/prisma/language-tools/issues/696)
- [Remove the feature flag for nativeTypes for stabilization, so the native types logic is always active.](https://github.com/prisma/language-tools/issues/697)

Prisma Studio

- [Cannot edit BigInts](https://github.com/prisma/studio/issues/621)
- [Cannot view/edit Bytes](https://github.com/prisma/studio/issues/622)
- [createMany (preview flag) crashes Studio](https://github.com/prisma/studio/issues/623)

Prisma Engines

- [Implement database locking in the migration engine](https://github.com/prisma/prisma-engines/issues/1118)
- [Apply `clippy` to `migration-engine`](https://github.com/prisma/prisma-engines/issues/1386)
- [Apply `clippy` to `introspection-engine`](https://github.com/prisma/prisma-engines/issues/1388)
- [Apply `clippy` to `libs/datamodel`](https://github.com/prisma/prisma-engines/issues/1389)
- [Apply `clippy` to all `libs/*` (except datamodel)](https://github.com/prisma/prisma-engines/issues/1390)
- [Run clippy on CI](https://github.com/prisma/prisma-engines/issues/1453)

Check out the official Prisma roadmap

You can find all the features that are currently planned and in progress on our [roadmap](https://pris.ly/roadmap).

Credits

Huge thanks to safinsingh for helping!

2.16.1

Today, we introduce the `2.16.1` patch release.

This fixes a problem some users are having with certain Docker, MariaDB, MySQL or SQL Server configurations, preventing Prisma to connect with `localhost`. A recent Docker update caused a regression related to IPv6 and name resolution.

Prisma
- [Prisma can not connect to `localhost` for MySQL, MariaDB and SQL Server (mostly when running those via Docker) 5499](https://github.com/prisma/prisma/issues/5499)

Prisma Engines

- [Fix resolving on MySQL](https://github.com/prisma/prisma-engines/pull/1615)
- [Fix resolving on SQL Server](https://github.com/prisma/prisma-engines/pull/1611)

2.16.0

Today, we are excited to share the `2.16.0` stable release 🎉

🌟 **Help us spread the word about Prisma by starring the repo or [tweeting](https://twitter.com/intent/tweet?text=Check%20out%20the%20latest%20Prisma%20release%202.16.0%20%F0%9F%9A%80%0D%0A%0D%0Ahttps://github.com/prisma/prisma/releases/tag/2.16.0) about the release.** 🌟 

Major improvements

The Prisma CLI moves from the `prisma/cli` to the `prisma` npm package

Going forward, you can install the Prisma CLI via the `prisma` npm package:


npm install prisma --save-dev


or


yarn add prisma --dev


The reason for this is that a number of users were experiencing issues when running the `npx prisma` command. Without a local installation of the `prisma/cli` package, this would invoke the Prisma 1 CLI leading to an error message. From now on, `npx prisma` is _always_ going to work.

We will also deprecate the `prisma/cli` package. Please do a _find and replace_ across your codebase to transition over from `prisma/cli` to `prisma`. To make this transition easier, we'll keep publishing updates to both packages for another month and plan to stop updating the `prisma/cli` package with release `2.18.0`.

There are no changes to the `prisma/client` npm package name.

Efficient bulk creates with `createMany`

Insert data a whole lot faster with `createMany`. Here's an example:

ts
const result = await prisma.user.createMany({
data: [
{ email: "aliceprisma.io" },
{ email: "markprisma.io" },
{ email: "jackieprisma.io" },
{ email: "bobprisma.io" },
],
});

console.log(`Created ${result.count} users!`);


This feature is in preview right now. Enable it with the `createMany` preview flag:

prisma
generator client {
provider = "prisma-client-js"
previewFeatures = ["createMany"]
}


📚 **Documentation**: [Create multiple records](https://www.prisma.io/docs/concepts/components/prisma-client/crud#create-multiple-records)

Learn more in this [issue](https://github.com/prisma/prisma/issues/4998#issuecomment-766742955).

Order by relation fields with `orderBy`

Ever wish you could order posts by an author's name? Or sort transactions by account? Now you can! We've expanded `orderBy` to support ordering by relations:

ts
cons posts = await prisma.post.findMany({
orderBy: [
{
author: {
name: "asc",
},
},
],
});


This feature is in preview right now. Enable it with the `orderByRelation` preview flag:

prisma
generator client {
provider = "prisma-client-js"
previewFeatures = ["orderByRelation"]
}


📚 **Documentation**: [Sort by relation](https://www.prisma.io/docs/concepts/components/prisma-client/filtering-and-sorting#sorting)

Learn more in this [issue](https://github.com/prisma/prisma/issues/5008#issuecomment-768444693).

Improvements to the `nativeTypes` Preview feature

We are working hard on making the Prisma experience smoother for folks that are using the `nativeTypes` Preview feature and are getting close to releasing it for General Availability.

If you have any feedback for this feature, please share it on [GitHub](https://github.com/prisma/prisma/issues/4045).

New `Unsupported` type allows to surface _any_ database type in the Prisma schema

This release introduces a new `Unsupported` type in the Prisma schema. It acts as an _escape hatch_ and allows to surface fields in Prisma schema for database types that are not yet supported by Prisma. For example, MySQL's `POLYGON` type is not yet natively supported by Prisma, but can now be added to the Prisma schema using the `Unsupported("polygon")` type.

The new type is especially relevant during introspection where previously fields of unsupported types would have been commented out, they're now included in the Prisma schema and of type `Unsupported`.

Fields of the `Unsupported` type are added to the Prisma schema in either of two ways:

- via _introspection_ in cases when Prisma detects a database column with a type that is not yet natively supported by Prisma
- _manually_ in combination with Prisma Migrate; in this case Prisma Migrate generates a SQL migration with the type that's provided as an argument to `Unsupported` in the Prisma schema

Note that fields of type `Unsupported` will **not** be surfaced in the Prisma Client API.

<!-- However, they can be accessed using plain SQL queries submitted with `$queryRaw`. -->

Example with Prisma Migrate

Here's an example of the new `Unsupported` type that uses MySQL's [`multilinestring`](https://dev.mysql.com/doc/refman/8.0/en/gis-linestring-property-functions.html):

prisma
generator client {
provider = "prisma-client-js"
previewFeatures = ["nativeTypes"]
}

datasource db {
provider = "mysql"
url = env("DATABASE_URL")
}

model User {
id Int id default(autoincrement())
email String unique
name String?
bio Unsupported("multilinestring") unique
}


Prisma Migrate generates the following SQL for the `User` model:

sql
CREATE TABLE `User` (
`id` INTEGER NOT NULL AUTO_INCREMENT,
`email` VARCHAR(191) NOT NULL,
`name` VARCHAR(191),
`bio` multilinestring NOT NULL,

UNIQUE INDEX `User.email_unique`(`email`),
UNIQUE INDEX `User.bio_unique`(`bio`),
PRIMARY KEY (`id`)
);


How `Unsupported` fields affect the Prisma Client API

Since Prisma Client doesn't yet "understand" the `Unsupported` type and therefore cannot read or write to its fields, we've also disabled creates and upserts on models that have a required `Unsupported` field without a default value. This prevents constraint violations at runtime.

To make this explicit, a new `ignore` attribute is added to the models that contain fields of type `Unsupported` during introspection:

prisma
model User {
id Int id default(autoincrement())
location Unsupported("point")

ignore
}


ts
// Not permitted because the database requires a `location`, but it can't be
// provided because the `point` type is unsupported by Prisma Client.
const user = await prisma.user.create({});


If the `ignore` attribute is added to a model, the relation fields of that model on other models will be annotated with the `ignore` attribute, for example:

prisma
model User {
id Int id default(autoincrement())
location Unsupported("point")

ignore
}

model Post {
id Int id default(autoincrement())
title String
author User ignore
}


New notation for default values via `dbgenerated()`

`dbgenerated()` in the `default` field directive can now take a `String` argument that enables developers to reflect database-level default values that are not yet natively supported by Prisma.

This changes the signature of the attribute from `dbgenerated()` to `dbgenerated(default: String)`. As an example, you can use `default(dbgenerated("''"))` to define an empty string as the default value for a column in MySQL.

These default values will be surfaced when introspecting the database or created/changed when defined manually in combination with Prisma Migrate.

This feature can be used alongside the new `Unsupported` type as well as with regular Prisma types.

Examples with Prisma Migrate

_Setting a default value on a `multilinestring` column_:

prisma
generator client {
provider = "prisma-client-js"
previewFeatures = ["nativeTypes"]
}

datasource db {
provider = "mysql"
url = env("DATABASE_URL")
}

model User {
id Int id default(autoincrement())
email String unique
name String?
bio Unsupported("multilinestring") unique default(dbgenerated("''"))
}


Prisma Migrate generates the following SQL for the `User` model:

sql
CREATE TABLE `User` (
`id` INTEGER NOT NULL AUTO_INCREMENT,
`email` VARCHAR(191) NOT NULL,
`name` VARCHAR(191),
`multilinestringField` multilinestring NOT NULL DEFAULT '',

UNIQUE INDEX `User.email_unique`(`email`),
UNIQUE INDEX `User.bio_unique`(`bio`),
PRIMARY KEY (`id`)
);


_Setting a default value for UUIDs via the `pgcrypto` PostgreSQL extension_:

prisma
model User {
id String id db.Uuid default(dbgenerated("gen_random_uuid()"))
name String?
}


Prisma Migrate generates the following SQL for the `User` model:

sql
CREATE TABLE "User" (
"id" UUID NOT NULL DEFAULT gen_random_uuid(),
"name" TEXT,

PRIMARY KEY ("id")
);


Note that the example above requires the corresponding extension to be enabled (in this case: `CREATE EXTENSION "pgcrypto";`).

New native type attributes available on PostgreSQL

We've added new native types for the `postgresql` provider. Here's an overview of the new type mappings:

| PostgreSQL | Prisma | Note |
| ---------- | --------- | ------------------------------- |
| `Inet` | `String` | |
| `Money` | `Decimal` | |
| `Oid` | `Int` | |
| `Citext` | `String` | Requires the `Citext` extension |

Here's an example that uses the four new types in a Prisma schema:

prisma
generator client {
provider = "prisma-client-js"
previewFeatures = ["nativeTypes"]
}

datasource db {
provider = "postgresql"
url = env("DATABASE_URL")
}

model User {
id Int id default(autoincrement())
ipAddress String? db.Inet
balance Decimal db.Money
oid Int db.Oid
citextName String db.Citext
}


Prisma Migrate generates the following SQL for the `User` model:

sql
CREATE TABLE "User" (
"id" SERIAL NOT NULL,
"ipAddress" INET,
"balance" MONEY NOT NULL,
"oid" OID NOT NULL,
"citextName" CITEXT NOT NULL,
PRIMARY KEY ("id")
);


More changes to the `nativeTypes` Preview feature

- When using the `nativeTypes` Preview feature, introspection will only render a native attribute if the column type does _not_ map to Prisma's corresponding default type. This might remove any existing type annotations upon (re-)introspection where the default mapping is currently in place.
- **MySQL**
- Columns of type `BIT(1)` can now be mapped to Prisma's `Boolean` type as well using the `Bit` native type attribute, e.g. `myField Boolean db.Bit(1)`.
- Default mapping for Prisma's `Float` type has been changed from `DECIMAL(65,30)` to `Double`.
- **PostgreSQL**
- Default mapping for Prisma's `Float` type has been changed from `DECIMAL(65,30)` to `Double`.
- **SQLite**
- Default mapping for Prisma's `Decimal` type has been changed from `REAL` to `DECIMAL`.

<details><summary>Expand for some more info about how this affects current users</summary>

PostgreSQL and MySQL users

- If no action is taken, the next time a new migration is created with `prisma migrate dev`, Prisma Migrate will generate DDL statements to change columns of Prisma's type `Float` to use `Double` instead of `Decimal`. These changes may lead to rounding errors due to differences in precision.
- If changing the underlying column is not desired, users can specify `Decimal` and continue using that as as the column type.
- Steps involved:
1. make sure the preview feature flag for native types is enabled
2. Change the field to be of scalar type `Decimal`
3. use the native type notation to pin the underlying type to `Decimal` or re-introspect your database with prisma introspect after enabling native types
- Example before: `myField Float`
- Example after: `myField Decimal db.Decimal(65,30)`

SQLite

- If you were using `Decimal` before on SQLite, with the native type feature flag enabled, Prisma Migrate will change the type in the next migration from `REAL` to `DECIMAL`.
- This can be avoided by changing the scalar type in the Prisma schema from `Decimal` to `Float`, or running re-introspection which will do the same.

</details>

<!-- Skip native type syntax for default types during (re-)introspection

When re-introspecting a database and the native type preview feature flag is enabled, Prisma will not render the native type notation for fields that are using Prisma's default column types.

It will:

- omit (or remove) the native type notation for any field which is using the default mapping, e.g. `name String?` for a field of type `varchar(191)` on MySQL (new behavior)
- render (or ad the native type notation for all other fields, e.g. `name String? db.VarChar(50)` for a field of type `varchar(50)` on MySQL (previous behavior) -->

`queryRaw` Breaking Changes

On MySQL _only_, fields of type `Boolean` are stored as `TINYINT(1)` in the database. We no longer coerce the value to a Boolean. That means `queryRaw` now returns integers of value `0` or `1` instead of `true` or `false` for `Boolean` fields.

Host Prisma Studio on Vercel

You can host your own instance of Prisma Studio on Vercel by following the instructions in the README of this [example repo](https://github.com/prisma/studio-vercel-guide).

More improvements

- You can now skip seeding when calling `prisma migrate dev` or `prisma migrate reset` with the `—-skip-seed` flag.
- You can now use the `--schema` option on the `prisma db seed` command to execute the command with a custom Prisma schema location.

Prisma Client Go gets dynamic filters

Give your users more control over how they filter and order their data. Build up filters over time instead of all at once.

Here's an example of setting specific attributes dynamically:

go
func CreateUser(w http.ResponseWriter, r *http.Request) {
var params []db.UserSetParam
email := r.PostFormValue("email")
kind := r.PostFormValue("kind")
if kind == "customer" {
// Set the referrer for users of type customer only
params = append(params, db.User.Referer.Set(r.Header.Get("Referer"))
}
user, err := client.User.CreateOne(
db.User.Kind.Set(kind),
db.User.Email.Set(email),
params...,
).Exec(r.Context())
// ... Handle the response
}


Learn more in the [Go documentation](https://github.com/prisma/prisma-client-go/blob/master/docs/reference/16-dynamic-queries.md).

Fixes and improvements

Prisma Client

- [Improve Prisma Client error handling](https://github.com/prisma/prisma/issues/3756)
- [TypeScript deploy "Cannot find module `.prisma/client`"](https://github.com/prisma/prisma/issues/5266)
- [Environmental variables conflict](https://github.com/prisma/prisma/issues/4789)
- [Inconsistent DMMF for relation lists](https://github.com/prisma/prisma/issues/4808)
- [querying an integer from a mysql tinyint(1) column fails](https://github.com/prisma/prisma/issues/4981)
- [Efficiently create many records](https://github.com/prisma/prisma/issues/4998)
- [Support Order by Relations](https://github.com/prisma/prisma/issues/5008)
- [PANIC: 1](https://github.com/prisma/prisma/issues/5073)
- [PANIC: 1, select same model twice in different levels](https://github.com/prisma/prisma/issues/5092)
- [PANIC: called `Result::unwrap()` on an `Err` value: Could not parse stored DateTime string: 2020-11-27 01:17:30 (input contains invalid characters)](https://github.com/prisma/prisma/issues/5096)
- [Narrow type for `rejectOnNotFound`](https://github.com/prisma/prisma/issues/5190)
- [Remove misleading "in use" numbers from Connection Pool timeout error message](https://github.com/prisma/prisma/issues/5228)
- [`count` query not working in react-prisma](https://github.com/prisma/prisma/issues/5271)

Prisma Migrate

- [Error: Error in migration engine. Reason: [C:\Users\runneradmin\.cargo\git\checkouts\quaint-9f01e008b9a89c14\6efc6f6\src\connector\postgres\error.rs:138:29] index out of bounds: the len is 1 but the index is 1 ](https://github.com/prisma/prisma/issues/4606)
- [Better error message when seeding if dependencies are missing](https://github.com/prisma/prisma/issues/5182)
- [DB seed does not work with custom schema location](https://github.com/prisma/prisma/issues/5213)
- [Do not render specific native notation when the underlying column matches the default mapping.](https://github.com/prisma/prisma/issues/5218)
- [Improve Migrate automatic panic reports by including the command ran](https://github.com/prisma/prisma/issues/5239)
- [Introspection: Remove comments for unsupported fields](https://github.com/prisma/prisma/issues/5309)
- [Improvement: Optionally skip seeding during migrate reset](https://github.com/prisma/prisma/issues/5317)

Language tools (e.g. VS Code extension)

- [Support for Unsupported, dbgenerated() and ignore](https://github.com/prisma/language-tools/issues/679)

Prisma Studio

- [Feature Request: Run prisma studio remotely](https://github.com/prisma/studio/issues/601)
- [`Open in new tab` for relation lists does not work as expected](https://github.com/prisma/studio/issues/612)

Prisma Engines

- [Change default mapping of scalar type `Float`](https://github.com/prisma/prisma-engines/issues/1287)
- [Query Engine is generating `min` and `max` aggregate for Json types to DMMF](https://github.com/prisma/prisma-engines/issues/1496)
- [Test `ldd` output of engines](https://github.com/prisma/prisma-engines/issues/1538)

Credits

Huge thanks to aruld for helping!

2.15.0

Today, we are excited to share the `2.15.0` stable release 🎉

🌟 **Help us spread the word about Prisma by starring the repo or [tweeting](https://twitter.com/intent/tweet?text=Check%20out%20the%20latest%20Prisma%20release%202.15.0%20%F0%9F%9A%80%0D%0A%0D%0Ahttps://github.com/prisma/prisma/releases/tag/2.15.0) about the release.**

Major improvements

Prisma Migrate now supports native database types (Preview)

In 2.11.0, we introduced support for [native database types](https://www.prisma.io/docs/concepts/components/preview-features/native-types) in the Prisma schema that allow you to map Prisma's scalar types to more specific types in the underlying database. However, these have not been compatible with the current Preview version of Prisma Migrate yet.

This release makes it possible to use Prisma Migrate with the native type annotations in your Prisma schema!

<details><summary>Expand for an example usage of Prisma Migrate with native types</summary>

Here's an example that uses several type annotations:

prisma
generator client {
provider = "prisma-client-js"
previewFeatures = ["nativeTypes"]
}

datasource db {
provider = "postgresql"
url = env("DATABASE_URL")
}

model Post {
id Int id default(autoincrement()) db.Integer
published Boolean default(false)
content String? db.VarChar(1000)
title String db.VarChar(191)
buffer Bytes?
}


Running a migration using the `prisma migrate` command, the following SQL is created:

sql
CREATE TABLE "Post" (
"id" SERIAL,
"published" BOOLEAN NOT NULL DEFAULT false,
"content" VARCHAR(1000),
"title" VARCHAR(191) NOT NULL,
"buffer" BYTEA,
PRIMARY KEY ("id")
);


</details>



Integrated database seeding (Preview)

A common requirement, especially for local development, is the ability to quickly seed your database with initial data. This is now possible with Prisma using the new `prisma db seed` command which is introduced in Preview in this release. Seeding is currently supported via scripts written in TypeScript, JavaScript, Go and Shell.

The command expects a file called `seed` with the respective file extension _inside your main `prisma` directory_.

- JavaScript: `prisma/seed.js`
- TypeScript: `prisma/seed.ts`
- Go: `prisma/seed.go`
- Shell: `prisma/seed.sh`

<details><summary>Expand for an example seeding workflow using TypeScript</summary>

For example, this `prisma/seed.ts` file could be invoked using the new command:

ts
// prisma/seed.ts

import { PrismaClient } from 'prisma/client'

const prisma = new PrismaClient()

// A `main` function so that we can use async/await
async function main() {
const newUser = await prisma.user.create({
data: {
email: "sarahprisma.io"
}
})
console.log(`new user created`, newUser.id)
}

main()
.catch((e) => {
console.error(e)
process.exit(1)
})
.finally(async () => {
await prisma.$disconnect()
})


To execute the seeding, run the new command with the `--preview-feature` flag:


prisma db seed --preview-feature


</details>

Please provide feedback for the new `prisma db seed` command [here](https://github.com/prisma/prisma/issues/5161).



Throw exceptions in `findFirst` and `findUnique` queries if no record is found

With the new `rejectOnNotFound` option, you can now tell Prisma Client to throw an exception when `findFirst` or `findUnique` does not find any records.

Here's an example:

ts
const user = await client.user.findUnique({
where: {
id: 10,
},
rejectOnNotFound: true
})
// Throws "NotFoundError: No User found" if the
// user with id = 10 does not exist.


If you omit `rejectOnNotFound`, these calls continue to return `undefined`.

Improved API for filtering arrays in PostgreSQL

We've added some new capabilities to your `where` condition for filtering arrays in PostgreSQL:

- `has`: a value is contained within the array
- `hasEvery`: all values are contained within the array
- `hasSome`: at least one values is contained in the array
- `isEmpty`: the array is empty

Here's an example:

prisma
model User {
id Int id
roles Role[]
}

enum Role {
ADMIN
EDITOR
READER
}


ts
const admin = await prisma.user.findFirst({
where: {
id: 1,
roles: {
has: 'ADMIN'
}
}
})


Learn more about this feature from this [GitHub comment](https://github.com/prisma/prisma/issues/5010#issuecomment-758777737).

More powerful counting of records using `select`

When using `count` queries, you can provide a number of options, e.g. for filtering. This release introduces the `select` option for `count` queries which lets you filter for non-null values of _multiple_ fields in a single query.

Assume you have this `User` model with a number of optional fields:

prisma
model User {
id Int id default(autoincrement()) db.Integer
createdAt DateTime default(now())
name String?
email String?
birthday DateTime?
}


You can send the following query to retrieve the count of records that contain non-null values for the respective field:

ts
const userCounts = await prisma.user.count({
select: {
name: true,
email: true,
birthday: true
}
})


This will return an object with the following structure, where the value of each field indicates how many records in the database contain a value for it:

ts
{
name: 2,
email: 0,
birthday: 1
}


This is also works with `aggregate` and `groupBy`:

ts
// new possibility:
const usersAggregation = await prisma.user.aggregate({
count: { name: true }
})

// same for group by:
const groupedByName = await prisma.user.aggregate({
by: ["name"],
count: true
})

// or more fine-grained control over the fields to be counted
const groupedByNameCount = await prisma.user.aggregate({
by: ["name"],
count: { name: true, _all: true }
})


Modifying relations by directly setting foreign keys is now stable

In 2.11.0, we introduced the `uncheckedScalarInputs` preview flag which allowed you to modify relations by directly setting foreign keys in your queries (as opposed to using a nested write with the `connect` option).

Fire up that delete key because you can now remove this flag from your Prisma schema.

diff
generator client {
provider = "prisma-client-js"
- previewFeatures = ["uncheckedScalarInputs"]
}


As a reminder, this allows you to set foreign keys directly:

ts
// An example of the new API that directly sets the foreign key
const user = await prisma.profile.create({
data: {
bio: 'Hello World',
userId: 42
},
})

// If you prefer, you can still use the previous API via `connect`
const user = await prisma.profile.create({
data: {
bio: 'Hello World',
user: {
connect: { id: 42 }, // sets userId of Profile record
},
},
})


Read more about in the [documentation on relation queries.](https://www.prisma.io/docs/concepts/components/prisma-client/relation-queries#nested-writes)

More improvements for Prisma Migrate

- Prisma Migrate now detects when the migrations don’t match the configured `provider` on your `datasource` block, for example when the migrations have been created with `sqlite` but the `provider` is now set to `postgresql`. Prisma Migrate will now print a helpful error message in these cases.
- `prisma migrate reset` can now be used in non-interactive environments (e.g. CI/CD) by passing the `--force` flag.
- The new seeding functionality (see above) will be automatically triggered whenever `prisma migrate reset` is called to reset and repopulate the database in development. It's also triggered when the database is reset interactively after calling `prisma migrate dev`.

Dark mode for Prisma Studio 🌒 & more powerful filtering

As of this release, Prisma Studio can be used in dark mode! You can use the _Settings_ icon in the top right corner to switch between light and dark mode.

We also included more powerful ways for you to filter the records of a table:

- Filter by `Json` fields
- Filter by the ID of a related model

Changes to the `nativeTypes` Preview feature

This version of introduces a few changes to the `nativeTypes` Preview feature:

- Removed the `Numeric` alias for `Decimal` on PostgreSQL, MySQL and Microsoft SQL Server. Replace any `Numeric` types with `Decimal` when you upgrade.
- Removed the `Serial`, `SmallSerial`, and `BigSerial` aliases for `INT AUTOINCREMENT`, `SMALLINT AUTOINCREMENT`, and `BIGINT AUTOINCREMENT` on PostgreSQL. You can use `Int default(autoincrement())`, `Int db.SmallInt default(autoincrement())` or `Int db.BigInt default(autoincrement())` when you upgrade.
- Renamed `JSON` to `Json` on MySQL.
- Renamed `Datetime` to `DateTime` on MySQL.

Breaking changes

- We've upgraded our RHEL base image from CentOS 6 to Amazon Linux 2. CentOS 6 reached end-of-life on November 30th, 2020. This may affect machines still running Amazon Linux 1. If you run into problems with this upgrade, please don't hesitate to [reach out](https://github.com/prisma/prisma/issues/new/choose).
- We've renamed the `FindOneModelArgs` and `FindManyModelArgs` type definitions to improve consistency. See [this issue](https://github.com/prisma/prisma-client-js/issues/647) for more details.
- Following the deprecation in [2.12.0](https://github.com/prisma/prisma/releases/tag/2.12.0), this release we've removed `findOne` and moved many of the Typescript types under the `Prisma` namespace.

Other

Transaction API for Prisma Client Go

Prisma Client Go now supports database transactions with a sparkly new `Transaction` API:

go
createUserA := client.User.CreateOne(
db.User.ID.Set("c"),
db.User.Email.Set("a"),
)
createUserB := client.User.CreateOne(
db.User.ID.Set("d"),
db.User.Email.Set("b"),
)
err := client.Prisma.Transaction(createUserA, createUserB).Exec(ctx)
if err != nil {
return err
}


Learn more about `Transaction` in the [reference](https://github.com/prisma/prisma-client-go/blob/master/docs/reference/12-transactions.md). If you'd like to try out Prisma Client Go, check out the [Quickstart](https://github.com/prisma/prisma-client-go/blob/master/docs/quickstart.md) for a gentle introduction.

SQL Server TLS Support on Mac

We now support secure connections between a Mac and SQL Server so your data is encrypted while in transit.

Fixes and improvements

Prisma Schema

- [Provide access keys used for a SSL connection](https://github.com/prisma/prisma/issues/1673)

Prisma Client

- [Stabilize `uncheckedScalarInputs`](https://github.com/prisma/prisma/issues/4962)
- [No warning is printed when `prisma/cli` and `prisma/client` have different versions in `package.json`](https://github.com/prisma/prisma/issues/3037)
- [Connected fields do not get an updated by updatedAt](https://github.com/prisma/prisma/issues/4146)
- [Error: Provided String, expected DateTime or DateTimeFieldUpdateOperationsInput](https://github.com/prisma/prisma/issues/4328)
- [$connect doesn't throw error on mysql connector if database is not reachable](https://github.com/prisma/prisma/issues/4335)
- [New count functionality](https://github.com/prisma/prisma/issues/4527)
- [Enable strict mode across the codebase](https://github.com/prisma/prisma/issues/4596)
- [Add types for `$on('beforeExit')`](https://github.com/prisma/prisma/issues/4733)
- [Error due to sockets file getting deleted](https://github.com/prisma/prisma/issues/4744)
- [Sqlite client: ConversionError(cannot parse integer from empty string)](https://github.com/prisma/prisma/issues/4778)
- [Array relation unpack error](https://github.com/prisma/prisma/issues/4791)
- [OR operator behaving like AND](https://github.com/prisma/prisma/issues/4831)
- [Remove deprecated features](https://github.com/prisma/prisma/issues/4882)
- [Slow Nested Queries - taking 2 seconds plus](https://github.com/prisma/prisma/issues/4884)
- [Querying a relation field with include or select returns the wrong type](https://github.com/prisma/prisma/issues/4892)
- [Cannot read property 'isCanceled' of undefined](https://github.com/prisma/prisma/issues/4906)
- [Grouping by required fields should be not have nullable output type](https://github.com/prisma/prisma/issues/4987)
- [Enforce mutual exclusivity of `select` & `include` (in Client requests) through types](https://github.com/prisma/prisma/issues/5059)
- [PostgreSQL: "PANIC: column on null constraint violation error in /root/.cargo/git/checkouts/quaint-9f01e008b9a89c14/a1decce/src/connector/postgres/error.rs:67:35"](https://github.com/prisma/prisma-client-js/issues/609)
- [Fails inside node cluster - Address already in use](https://github.com/prisma/prisma-client-js/issues/632)
- [Rename FindOneModelArgs & FindManyModelArgs to ModelFindOneArgs and ModelFindManyArgs](https://github.com/prisma/prisma-client-js/issues/647)

Prisma Migrate

- [Prisma Migrate: Improve UX when switching providers](https://github.com/prisma/prisma/issues/4760)
- [Ability to use `prisma migrate reset` in non-interactive environments](https://github.com/prisma/prisma/issues/4773)
- [`prisma migrate reset` fails if the db is not already initialized](https://github.com/prisma/prisma/issues/4974)

Prisma Studio

- [Allow filtering of JSON fields](https://github.com/prisma/studio/issues/511)
- [Allow filtering by relation fields](https://github.com/prisma/studio/issues/520)
- [Linux app icon is incorrect](https://github.com/prisma/studio/issues/593)
- [Cannot open intended Model using Prisma Studio's search window with keyboard shortcut](https://github.com/prisma/studio/issues/603)


Prisma Engines

- [Fail CI if the rust build emits any warnings](https://github.com/prisma/prisma-engines/issues/1384)
- [Change return type of batch response type](https://github.com/prisma/prisma-engines/issues/1431)


Credits

Huge thanks to qsona, mikebobadilla, cyrus-za for helping!

2.14.0

We hope everyone enjoyed their holidays and recharged for 2021! Today, we are excited to share the `2.14.0` stable release 🎉

🌟 **Help us spread the word about Prisma by starring the repo or [tweeting](https://twitter.com/intent/tweet?text=Check%20out%20the%20latest%20Prisma%20release%202.14.0%20%F0%9F%9A%80%0D%0A%0D%0Ahttps://github.com/prisma/prisma/releases/tag/2.14.0) about the release.**

Major improvements

Group By queries are now in Preview

Prisma Client now supports group by queries! Opt-in to this feature by adding the `groupBy` flag to the `generator` block in your Prisma schema:

diff
generator client {
provider = "prisma-client-js"
+ previewFeatures = ["groupBy"]
}

model Agent {
id String id
name String
location String
rate Float
}


Now you can re-generate your Prisma Client to have access to the new `groupBy` API:


npx prisma generate


With the updated Prisma Client, you can invoke the new `groupBy` query:

ts
const locations = await client.agent.groupBy({
by: ['location'],
min: {
rate: true
},
})

// Result:
// [

2.13.1

Today, we are issuing the `2.13.1` patch release.

Fixes

- [Introspection: Reintrospection Bug on Relations 4582](https://github.com/prisma/prisma/issues/4582)
- [Prisma Client: Limitation when using `INSERT..OUTPUT` if the table has triggers on MSSQL](https://github.com/prisma/prisma/issues/4535)
- [Prisma Migrate: Removing a model with a foreign key fails on MSSQL](https://github.com/prisma/migrate/issues/667)
- [Prisma Migrate: Schema name in CREATE statements leads to errors when using enums](https://github.com/prisma/prisma/issues/4626)

Improvements

- [Prisma Migrate: Better user-facing error when prisma migrate fails to create the shadow database](https://github.com/prisma/prisma/issues/4571)

Page 20 of 44

Links

Releases

Has known vulnerabilities

© 2025 Safety CLI Cybersecurity Inc. All Rights Reserved.