Skip to content

Releases: prisma/prisma

4.7.1

02 Dec 10:41
Compare
Choose a tag to compare

4.7.0

29 Nov 16:59
127167c
Compare
Choose a tag to compare

🌟 Help us spread the word about Prisma by starring the repo or tweeting about the release. 🌟

Highlights

Interactive transactions are now Generally Available

After an extensive Preview phase and lots of great feedback from our community, we're excited to announce that interactiveTransactions is now Generally Available and production ready! 🚀

Interactive transactions allow you to pass an async function into a $transaction, and execute any code you like between the individual Prisma Client queries. Once the application reaches the end of the function, the transaction is committed to the database. If your application encounters an error as the transaction is being executed, the function will throw an exception and automatically rollback the transaction.

Here are some of the feature highlights we've built:

Here's an example of an interactive transaction with a Serializable isolation level:

await prisma.$transaction(
  async (prisma) => {
    // Your transaction...
  },
  {
    isolationLevel: Prisma.TransactionIsolationLevel.Serializable,
    maxWait: 5000,
    timeout: 10000,
  }
)

You can now remove the interactiveTransactions Preview feature in your schema.

Relation mode is Generally Available

This release marks relationMode="prisma" as stable for our users working with databases that don't rely on foreign keys to manage relations. 🎉

Prisma’s relation mode started as a way to support PlanetScale which does not allow you to create foreign keys for better online migration support. We transformed that into our Referential Integrity Emulation in 3.1.1 when we realised that more users could benefit from it, and then integrated it as the default mode for MongoDB, which generally does not have foreign keys. Prisma needed to use emulation to give the same guarantees.

We then realized the feature was more than just referential integrity and affected how relations work. To reflect this, we renamed the feature to relation mode and the datasource property to relationMode in 4.5.0

Index warnings for relationMode = "prisma"

In this release, we've added a warning to our Prisma schema validation that informs you that the lack of foreign keys might result in slower performance — and that you should add an @@index manually to your schema to counter that. This ensures your queries are equally fast in relation mode prisma as they are with foreign keys.

With relationMode = "prisma", no foreign keys are used, so relation fields will not benefit from the index usually created by the relational database under the hood. This can lead to slower performance when querying these fields. We recommend manually adding an index.

We also added a fix to our VS Code extension to help adding the suggested index with minimal effort:

If you are currently using the Preview feature flag to enable relation mode, you can now remove referentialIntegrity from the previewFeatures in your generator client block in your Prisma schema.

For more information, check out our updated relation mode documentation.

Prisma Client Extensions (Preview)

This release adds Preview support for Prisma Client Extensions. This feature introduces new capabilities to customize and extend Prisma Client. Today we are opening up four areas for extending Prisma Client:

Prisma Client Extensions are self-contained scripts that can tweak the behavior of models, queries, results, and the client (Prisma Client) as a whole. You can associate a single or multiple extensions with an extended client to mix and match Prisma to your needs.

Prisma Client Extensions enables many use cases such as defining virtual fields, custom validation, and custom queries.

It also enables you to share your client extensions with others and import client extensions developed by others into your project.

For example, given the following schema:

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

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

model User {
  id        Int     @id @default(autoincrement())
  email     String  @unique
  firstName String?
  lastName  String
}

You can create a computed field called fullName as follows:

import { PrismaClient } from "@prisma/client"

const prisma = new PrismaClient()
  .$extends({
    result: {
      user: {
        fullName: {
          // the dependencies
          needs: { firstName: true, lastName: true },
          compute(user) {
            // the computation logic
            return `${user.firstName} ${user.lastName}`
          },
        },
      },
    },
  })

We're excited to see what you build with them! For more information, check out our docs and let us know what you think in this GitHub issue.

Multi-schema support for PostgreSQL (Preview)

We're pleased to announce that this release adds support for multi-schema support for PostgreSQL. The ability to query and manage multiple database schemas has been a long-standing feature request from our community.

This release adds support for the following:

  • Introspecting databases that organize objects in multiple database schemas
  • Managing multi-schema database setups directly from Prisma schema
  • Generating migrations that are database schema-aware with Prisma Migrate
  • Querying across multiple database schemas with Prisma Client

If you already have a PostgreSQL database using multiple schemas, you can quickly get up and running using prisma db pull — on enabling the Preview feature and specifying the schemas in the datasource block similar to the example below.

You can get started with defining multiple schemas in your Prisma schema as follows:

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

datasource db {
  provider = "postgresql"
  url      = env("DATABASE_URL")
  schemas  = ["base", "transactional"]
}

model User {
  id     Int     @id
  orders Order[]

  @@schema("base")
}

model Order {
  id      Int  @id
  user    User @relation(fields: [id], references: [id])
  user_id Int

  @@schema("transactional")
}

Then generate and apply the changes to your database with prisma migrate dev.

We want to thank all our users for helping us design the feature since the early proposal on GitHub up to our current Preview release.

For further details, refer to our documentation and let us know what you think in this GitHub issue.

Request for feedback

Our Product team is currently running a survey for designing Database Views support for Prisma and we would appreciate your feedback.

Fixes and improvements

Prisma Client

Read more

4.6.1

10 Nov 15:09
5c24884
Compare
Choose a tag to compare

4.6.0

08 Nov 16:47
3bb8243
Compare
Choose a tag to compare

🌟 Help us spread the word about Prisma by starring the repo or tweeting about the release. 🌟

Highlights

Interactive Transactions for Prisma Data Proxy (Preview)

In 3.8.0, we disabled the interactiveTransactions Preview feature when using the Prisma Data Proxy. This was because the API was not yet supported.

In this release, we're removing the limitation. You can now try the Preview version of interactive transactions with the Prisma Data Proxy. Re-generate Prisma Client using prisma generate --data-proxy after enabling the Preview feature.

Note: The interactiveTransactions Preview feature flag is still needed. We will remove this in a future version when the feature is stable.

Try it out and let us know your thoughts in our interactive transactions feedback GitHub issue.

Native database level upserts for PostgreSQL, SQLite, and CockroachDB

Prisma’s upsert is one of its most powerful and most convenient APIs. In this release, Prisma will now default to the native database upsert for PostgreSQL, SQLite, and CockroachDB whenever possible.

Prisma will use the native database upsert if:

  • There are no nested queries in the upsert's create and update options
  • The query modifies only one model
  • There is only one unique field in the upsert's where option
  • The unique field in the where option and the unique field in the create option have the same value

Prisma Client's upsert operation was implemented on a Prisma-level and did not use the native database implementations like, e.g., INSERT .. ON CONFLICT .. UPDATE SET. This allowed Prisma to also upsert nested queries.

The Prisma-implementation came at a cost. In some scenarios, it was more likely for a transaction to roll back because of a conflict when multiple upsert operations were being executed in parallel, and the multiple queries often took longer than the native database query would have taken.

Try it out and let us know what you think. If you run into any issues, don't hesitate to create a GitHub issue.

Relation Mode improvements (Preview)

In 4.5.0, we renamed the "Referential Integrity" Preview feature to "Relation Mode". We also changed the datasource property name of the feature to relationMode.

In this release, we fixed all remaining known bugs of relationMode = "prisma" and cleaned up our documentation. You can now read about Relation mode on its own documentation page which is up to date with the implementation.

If you encounter any problems please comment on our feedback issue. We plan to make this Generally Available soon.

extendedWhereUnique improvements (Preview)

In 4.5.0, we introduced the extendedWhereUnique Preview feature to allow filtering for non-unique properties in unique where queries. In this release, we're adding new rules to decide when concurrent findUnique queries get batched into a findMany query.

Unfortunately, we forgot to adapt our findUnique query batch optimization, which turns multiple concurrent findUnique queries into a single findMany query when possible — GitHub issue.

Therefore, findUnique queries will get batched into a findMany query if:

  • All criteria of the filter must be on scalar fields (unique or non-unique) of the same model you're querying
  • All criteria must use the equal's filter, whether that's via the shorthand or explicit syntax (where: { field: <val>, field1: { equals: <val> } })

Conversely, suppose the filter object contains any boolean operators, relation filters, or scalar filters that are not using equals. Prisma will fall back to executing the findUnique queries independently.

Let us know your thoughts and share your feedback on the Preview feature in this GitHub issue.

Fixes and improvements

Prisma Client

Prisma

Language tools (e.g. VS Code)

Design Partner Program

Are you building data-intensive applications in serverless environments using Prisma? If so, you should join our Design Partner Program to help us build the tools that best fit your workflows!

The Design Partner Program aims to help development teams solve operational, data-related challenges in serverless environments. Specifically, we’re looking to build tools that help with the following problems:

  • Solutions to listen and react to database changes in real time are either brittle or too complex to build and operate.
  • Coordinating workflows executed via a set of isolated functions or services spreads that coordination logic across these services instead of keeping it centralized and maintainable. This adds unnecessary overhead and clutter to your business logic.
  • Optimizing the data access layer for scaling performance often involves projecting data into denormalized views, or caching. These methods come with complex logic to figure out strategies for cache invalidation or preventing to use stale data.
  • Building web applications on modern Serverless platforms such as Vercel or Netlify often breaks down as soon as you need to execute on any of the topics listed above. This pushes to re-platform on a traditional infrastructure, delaying projects, and losing productivity benefits offered by Vercel or Netlify.

Submit an application through our applicati...

Read more

4.5.0

18 Oct 17:55
c1afd29
Compare
Choose a tag to compare

🌟 Help us spread the word about Prisma by starring the repo or tweeting about the release. 🌟

Major improvements

Filter for non-unique properties in unique where queries (Preview)

In this release, we are adding support for non-unique properties inside the where statement for queries that operate on a unique record (e.g.: findUnique, update, delete, etc.). This was not possible in the past, as we only allowed unique fields as filters inside the where statement for the queries in question.

There are use cases where a query that operates on a unique record requires further filtering by non-unique properties. For example, for the following model:

model Article {
  id      Int    @id @default(autoincrement())
  content String
  version Int
}

Let’s say that you would like to update the Article with an id of “5”, but only if the version equals "1":

await prisma.article.update({
    where: { id: 5, version: 1 }, // `version` field was not available before Prisma 4.5.0
    data: {
        content: "Incredible new story",
        version: { increment: 1 },
    },
});

With 4.5.0, we are adding support to specify any number of non-unique fields in your where statement, as long as you have at least one unique field.

To use it, enable the Preview feature flag:

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

To learn more about this feature and about use cases where it can be useful, please check out our documentation. For feedback, please leave a comment on the GitHub issue.

PostgreSQL extension management (Preview)

We are excited to add support for declaring PostgreSQL extensions in the Prisma schema. The feature comes with support for introspection and migrations. This will allow you to adopt, evolve and manage which PostgreSQL database extensions are installed directly from within your Prisma schema.

💡 This feature adds support to manage PostgreSQL extensions in Prisma schema. It does not provide additional query capabilities and datatypes in Prisma Client.

To try this feature, enable the Preview feature flag:

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

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

Now you will be able to use the new extensions property in the datasource block of your Prisma schema.

datasource db {
  provider   = "postgresql"
  url        = env("DATABASE_URL")
  extensions = [hstore(schema: "myHstoreSchema"), pg_tgrm, postgis(version: "2.1")]
}

⚠️ To avoid noise from introspection, we currently only introspect the following allow-list: citext, pgcrypto, uuid-ossp, and postgis. But you can add and configure any extension to your Prisma schema manually.

Please visit our documentation to learn more about this feature or leave a comment with feedback on the GitHub issue.

Change to Referential Integrity — property in datasource block renamed to relationMode (Preview)

To prepare Prisma Client’s emulation of relations for general availability, we are releasing several improvements to the referentialIntegrity Preview feature.

We decided to rename the feature to Relation Mode. We think this closer reflects what this feature does and distinguishes it from integrity management on the database level. The related property in the datasource block of the Prisma schema has also been changed from referentialIntegrity to relationMode.

⚠️ The Preview feature flag inside the generator block of the Prisma schema is still called referentialIntegrity.

To use it, keep using the old referentialIntegrity Preview feature flag:

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

But use the new property name in the datasource:

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

We also removed the referential action NoAction for PostgreSQL and SQLite when using relationMode = "prisma" as we are not planning to support the details of the database behavior.

To learn more about relationMode, please check out the documentation or leave a comment on the GitHub issue.

Deno for Prisma Client for Data Proxy (Preview)

Deno is an alternative JavaScript runtime that can replace Node.js to run JS and TS apps. It aligns itself closely with web technologies, claims to be secure by default, and supports TypeScript out of the box.

Today we are releasing initial support for Prisma with Deno via an integration for our Prisma Client for Data Proxy. This feature was developed together with the amazing team at Deno 🦕.

To use Prisma Client in a Deno project, add the deno Preview feature flag to your Prisma schema and define a folder as output (this is required for Deno):

generator client {
  provider        = "prisma-client-js"
  previewFeatures = ["deno"]
  output          = "../generated/client"
}

Now you can generate Prisma Client with the Data Proxy using the command npx prisma generate --data-proxy. Then use Prisma Client in your Deno script with the following import:

import { PrismaClient } from './generated/client/deno/edge.ts'

const prisma = new PrismaClient()

async function main() {
    const users = await prisma.user.findMany()
    console.log({ users })
}

main()

You can also deploy an app built and configured like this on Deno Deploy, Deno’s deployment platform. Read this guide in our documentation for a full example and individual steps.

For feedback, please comment on this GitHub issue.

Fixed “Invalid string length” error in Prisma Studio and Prisma Data Platform Data Browser

Many people were having issues with an "Invalid string length" error both in Prisma Studio and Prisma Data Platform Data Browser. This issue can be resolved through this workaround. With this release, the root cause of this issue has been fixed and it should not occur again.

Updated proposal for Client Extensions: request for comments

In 4.3.0, we shared a proposal for Prisma Client Extensions on Github. We received a lot of great feedback, which we have incorporated into a new proposal.

If you’re interested, please head over to the new proposal in GitHub and tell us what you think. Thank you!

Fixes and improvements

Prisma

Prisma Client

Prisma Migrate

  • [`postgresqlExte...
Read more

4.4.0

27 Sep 18:29
b3c3f07
Compare
Choose a tag to compare

🌟 Help us spread the word about Prisma by starring the repo or tweeting about the release. 🌟

Major improvements

General improvements

In the last sprint, we focused our efforts on squashing as many bugs as we could. You can find the full list of improvements and bug fixes in the Fixes and improvements section below.

Some of the improvements we made include but are not limited to:

  • Improved optimistic concurrency control (GitHub issue)
  • Improved decimal precision
  • Improved handling of big amounts of prepared statement placeholders:
    Databases impose limits when they hit a specific number, and when a query (either generated by Prisma Client or provided by the user directly as a raw query) hits it some users ran into a misleading Can't reach database server error message (GitHub issue). The error message will now be more useful (P2035 error code), and Prisma Client should not cause these errors anymore.

If you notice any regression, please make sure to create a GitHub issue. We touched a lot of code in this sprint, and even though we are confident in our tests, something might have slipped through the cracks. We'd like to fix the regressions as soon as possible.

isolationLevel for sequential transaction operations

In version 4.2.0, we added support for setting transaction isolation levels for interactive transactions (Preview). You can now define isolation levels for sequential transaction operations: prisma.$transaction([]).

Isolation levels describe different types of trade-offs between isolation and performance that databases can make when processing transactions. Isolation levels determine what types of data leaking can occur between transactions or what data anomalies can occur.
To set the transaction isolation level, use the isolationLevel option in the second parameter of the API. For example:

await prisma.$transaction(
  [
    // sequential operations
    prisma.user.create({ data: {/** args */ } }),
    prisma.post.create({ data: {/** args  */ } })
  ],
  {
    isolationLevel: Prisma.TransactionIsolationLevel.Serializable
  }
)

Prisma Client supports the following isolation levels if they're available in your database provider:

  • ReadCommitted
  • ReadUncommitted
  • RepeatableRead
  • Serializable
  • Snapshot

Learn more about it in our documentation.

New P2034 error code for transaction conflicts or deadlocks

When using certain isolation levels, it is expected that a transaction can fail due to a write conflict or a deadlock, throwing an error. One way to solve these cases is by retrying the transaction.

To make this easier, we're introducing a new PrismaClientKnownRequestError with the error code P2034: "Transaction failed due to a write conflict or a deadlock. Please retry your transaction". You can programmatically catch the error and retry the transaction. Here's an example showing how you can retry a transaction:

import { Prisma, PrismaClient } from '@prisma/client'

const prisma = new PrismaClient()
async function main() {
  const MAX_RETRIES = 5
  let retries = 0;

  let result;
  while (retries < MAX_RETRIES) {
    try {
      result = await prisma.$transaction(
        [
          prisma.user.deleteMany({ where: { /**  args */ } }),
          prisma.post.createMany({ data: { /**  args */ } })
        ],
        {
          isolationLevel: Prisma.TransactionIsolationLevel.Serializable
        }
      )
    } catch (error) {
      if (error.code === 'P2034') {
        retries++
        continue
      }
      throw error
    }
  }
}

Fixes and improvements

Prisma Client

Read more

4.3.1

01 Sep 18:24
Compare
Choose a tag to compare

Today, we are issuing the 4.3.1 patch release.

Fixes in Prisma Client

Fixes in Prisma CLI

4.3.0

30 Aug 16:24
333dd87
Compare
Choose a tag to compare

🌟 Help us spread the word about Prisma by starring the repo or tweeting about the release. 🌟

Major improvements

Field reference support on query filters (Preview)

We're excited to announce Preview support for field references. You can enable it with the fieldReference Preview feature flag.

Field references will allow you to compare columns against other columns. For example, given the following schema:

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

model Invoice {
  id     Int @id @default(autoincrement)
  paid   Int
  due    Int
}

You can now compare one column with another after running prisma generate, for example:

// Filter all invoices that haven't been paid yet
await prisma.invoice.findMany({
  where: {
    paid: {
      lt: prisma.invoice.fields.due // paid < due
    }
  }
})

Learn more about field references in our documentation. Try it out and let us know what you think in this GitHub issue.

Count by filtered relation (Preview)

In this release, we're adding support for the ability to count by a filtered relation. You can enable this feature by adding the filteredRelationCount Preview feature flag.

Given the following Prisma schema:

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

model User {
  id    Int     @id @default(autoincrement())
  email String  @unique
  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?
}

You can now express the following query with the Preview feature after re-generating Prisma Client:

// Count all user posts with the title "Hello!"
await prisma.user.findMany({
  select: {
    _count: {
      select: {
        posts: { where: { title: 'Hello!' } },
      },
    },
  },
})

Learn more in our documentation and let us know what you think in this issue

Multi-schema support (Preview)

In this release, we're adding very early Preview support of multi-schema support for PostgreSQL and SQL Server behind the multiSchema Preview feature flag. With it, you can write a Prisma schema that accesses models across multiple schemas.

Read further in this GitHub issue. Try it out and let us know what you think in this GitHub issue.

Prisma CLI exit code fixes

We've made several improvements to the Prisma CLI:

  • prisma migrate dev previously returned a successful exit code (0) when prisma db seed was triggered but failed due to an error. We've fixed this and prisma migrate dev will now exit with an unsuccessful exit code (1) when seeding fails.

  • prisma migrate status previously returned a successful exit code (0) in unexpected cases. The command will now exit with an unsuccessful exit code (1) if:

    • An error occurs
    • There's a failed or unapplied migration
    • The migration history diverges from the local migration history (/prisma/migrations folder)
    • Prisma Migrate does not manage the database' migration history
  • The previous behavior when canceling a prompt by pressing Ctrl + C was returning a successful exit code (0). It now returns a non-successful, SIGINT, exit code (130).

  • In the rare event of a Rust panic from the Prisma engine, the CLI now asks you to submit an error report and exit the process with a non-successful exit code (1). Prisma previously ended the process with a successful exit code (0).

Improved precision for the tracing Preview feature

Before this release, you may have occasionally seen some traces that took 0μs working with the tracing Preview feature. In this release, we've increased the precision to ensure you get accurate traces.

Let us know if you run into any issues in this GitHub issue.

prisma format now uses a Wasm module

Initially, the prisma format command relied on logic from the Prisma engines in form of a native binary. In an ongoing effort to make prisma more portable and easier to maintain, we decided to shift to a Wasm module.

prisma format now uses the same Wasm module as the one the Prisma language server uses, i.e. @prisma/prisma-fmt-wasm, which is now visible in prisma version command's output.

Let us know what you think. In case you run into any issues, let us know by creating a GitHub issue.

MongoDB query fixes

⚠️ This may affect your query results if you relied on this buggy behavior in your application.

While implementing field reference support, we noticed a few correctness bugs in our MongoDB connector that we fixed along the way:

  1. mode: insensitive alphanumeric comparisons (e.g. “a” > “Z”) didn’t work (GitHub issue)
  2. mode: insensitive didn’t exclude undefined (GitHub issue)
  3. isEmpty: false on lists types (e.g. String[]) returned true when a list is empty (GitHub issue)
  4. hasEvery on list types wasn’t aligned with the SQL implementations (GitHub issue)

JSON filter query fixes

⚠️ This may affect your query results if you relied on this buggy behavior in your application.
We also noticed a few correctness bugs in when filtering JSON values when used in combination with the NOT condition. For example:

await prisma.log.findMany({
  where: {
    NOT: {
      meta: {
        string_contains: "GET"
      }
    }
  }
})
Prisma schema
model Log {
  id      Int  @id @default(autoincrement())
  level   Level
  message String
  meta    Json
}

enum Level {
  Info
  Warn
  Error
}

If you used NOT with any of the following queries on a Json field, double-check your queries to ensure they're returning the correct data:

  • string_contains
  • string_starts_with
  • string_ends_with
  • array_contains
  • array_starts_with
  • array_ends_with
  • gt/gte/lt/lte

Prisma extension for VS Code improvements

The Prisma language server now provides Symbols in VS Code. This means you can now:

  • See the different blocks (datasource, generator, model, enum, and type) of your Prisma schema in the Outline view. This makes it easier to navigate to a block in 1 click
    A few things to note about the improvement are that:

    • CMD + hover on a field whose type is an enum will show the block in a popup
    • CMD + left click on a field whose type is a model or enum will take you to its definition.
  • Enable Editor sticky scroll from version 1.70 of VS Code. This means you can have sticky blocks in your Prisma schema, improving your experience when working with big schema files

Make sure to update your VS Code application to 1.70, and the Prisma extension to 4.3.0.

We'd also like to give a big Thank you to @yume-chan for your contribution!

Prisma Studio improvements

We've made several improvements to the filter panel which includes:

  • Refined filter panel

    • Reducing the contrast of the panel in dark mode
    • Ability to toggle filters in the panel
  • Refined error handling for MongoDB m-n relations
    Prisma Studio prevents fatal errors when interacting with m-n relations by explicitly disabling creating, deleting, or editing records for m-n relations

  • Multi-row copying
    You can select multiple rows and copy them to your clipboard as JSON objects using CMD + C on MacOS or Ctrl + C on Windows/ Linux

Prisma Client Extensions: request for comments

For the last couple of months, we've been working on a specification for an upcoming feature — Prisma Client extensions. We're now ready to share our proposed design and we would appreciate your feedback.

Prisma Client Extensions aims to provide a type-safe way to extend your existing Prisma Client instance. With Prisma Client Extensions you can:

  • Define computed fields
  • Define methods for your models
  • Extend your queries
  • Exclude fields from a model
    ... and much more!

Here’s a glimpse at how that will look:

cons...
Read more

4.2.1

10 Aug 14:32
Compare
Choose a tag to compare

4.2.0

09 Aug 11:52
cf9aba8
Compare
Choose a tag to compare

🌟 Help us spread the word about Prisma by starring the repo or tweeting about the release. 🌟

Major improvements

Prisma Client tracing support (Preview)

We're excited to announce Preview support for tracing in Prisma Client! 🎉

Tracing allows you to track requests as they flow through your application. This is especially useful for debugging distributed systems where each request can span multiple services.

With tracing, you can now see how long Prisma takes and what queries are issued in each operation. You can visualize these traces as waterfall diagrams using tools such as Jaeger, Honeycomb, or DataDog.

Read more about tracing in our announcement post and learn more in our documentation on how to start working with tracing.

Try it out and let us know what you think.

Isolation levels for interactive transactions

We are improving the interactiveTransactions Preview feature with the support for defining the isolation level of an interactive transaction.

Isolation levels describe different types of trade-offs between isolation and performance that databases can make when processing transactions. Isolation levels determine what types of data leaking can occur between transactions or what data anomalies can occur.

To set the transaction isolation level, use the isolationLevel option in the second parameter of the API. For example:

await prisma.$transaction(
  async (prisma) => {
    // Your transaction...
  },
  {
    isolationLevel: Prisma.TransactionIsolationLevel.Serializable,
    maxWait: 5000,
    timeout: 10000,
  }
)

Prisma Client supports the following isolation levels if they're available in your database provider:

  • ReadCommitted
  • ReadUncommitted
  • RepeatableRead
  • Serializable
  • Snapshot

Learn more about in our documentation. Try it out, and let us know what you think in this GitHub issue.

Renaming of Prisma Client Metrics

In this release, we've renamed the metrics — counters, gauges, and histograms — returned from prisma.$metrics() to make it a little easier to understand at a glance.

Previous Updated
query_total_operations prisma_client_queries_total
query_total_queries prisma_datasource_queries_total
query_active_transactions prisma_client_queries_active
query_total_elapsed_time_ms prisma_client_queries_duration_histogram_ms
pool_wait_duration_ms prisma_client_queries_wait_histogram_ms
pool_active_connections prisma_pool_connections_open
pool_idle_connections prisma_pool_connections_idle
pool_wait_count prisma_client_queries_wait

Give Prisma Client metrics a shot and let us know what you think in this GitHub issue

To learn more, check out our documentation.

Syntax highlighting for raw queries in Prisma Client

This release adds syntax highlighting support for raw SQL queries when using $queryRaw`` and $executeRaw`` . This is made possible using Prisma's VS Code extension.

Screenshot 2022-08-09 at 12 30 27

Note: Syntax highlighting currently doesn't work with when using parentheses, (), $queryRaw(), $executeRaw(), $queryRawUnsafe(), and $executeRawUnsafe().

If you are interested in having this supported, let us know in this GitHub issue.

Experimental Cloudflare Module Worker Support

We fixed a bug in this release that prevented the Prisma Edge Client from working with Cloudflare Module Workers.

We now provide experimental support with a workaround for environment variables.

Try it out and let us know how what you think! In case you run into any errors, feel free to create a bug report.

Upgrade to Prisma 4

In case you missed it, we held a livestream a few weeks ago and walked through issues you may run into while upgrading to Prisma 4 and how to fix them!

Request for feedback

Our Product teams are currently running two surveys to help close the feature gaps and improve Prisma.

If you have a use-case for geographical data (GIS) or full-text search/ indexes (FTS), we would appreciate your feedback on your needs:

Many thanks! 🙌🏽

Fixes and improvements

Prisma Client

Prisma

Language tools (e.g. VS Code)

Prisma Studio

Credits

Huge thanks to @shian15810, @zifeo, @lodi-g, @Gnucki, @apriil15, @givensuman, @peter-gy for helping!

Prisma Data Platform

We're working on the Prisma Data Platform — a collaborative environment for connecting apps to databases. It includes the:

  • Data Browser for navigating, editing, and querying data
  • Data Proxy for persistent, reliable, and scalable connection pooling for your database.
  • Query Console for experimenting with queries

Try it out and let us know what you think!

💼 We're hiring!

If you're interested in joining our growing team to help empower developers to build data-intensive applications, Prisma is the place for you.

We're looking for a Developer Advocate (Frontend / Fullstack) and Back-end Engineer: Prisma Data Platform.

Feel free to read the job descriptions and apply using the links provided.

📺 Join us for another "What's new in Prisma" livestream

Learn about the latest release and other news from the Prisma community by joining us for another "What's new in Prisma" livestream.

The stream takes place [on YouTube](https://youtu...

Read more