Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update prisma monorepo to v3 (major) #305

Closed
wants to merge 1 commit into from

Conversation

renovate[bot]
Copy link
Contributor

@renovate renovate bot commented Sep 13, 2021

WhiteSource Renovate

This PR contains the following updates:

Package Change Age Adoption Passing Confidence
@prisma/client (source) 2.16.1 -> 3.0.2 age adoption passing confidence
prisma (source) 2.16.1 -> 3.0.2 age adoption passing confidence

Release Notes

prisma/prisma

v3.0.2

Compare Source

Today, we are issuing the 3.0.2 patch release.

Fixes
Prisma CLI

v3.0.1

Compare Source

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.

Major improvements

Today's release is packed with many new features that are now Generally Available!

Here's a summary:

  • Referential Actions
  • Named Constraints
  • Microsoft SQL Server and Azure SQL Connector
  • Seeding with prisma db seed has been revamped
  • Node-API
  • Order by Aggregate in Group By
  • Order by Relation
  • Select Relation Count

Read 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 now Generally Available

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 Cats 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. 🚨

Named Constraints is now Generally Available

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:

  • The names of constraints in the database schema which are generated by Prisma Migrate and the prisma db push command.
  • The name mapping for the constraint in Prisma Client for 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. 🚨

Microsoft SQL Server and Azure SQL Connector is now Generally Available

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 🤓

Seeding with prisma db seed has been revamped and is now Generally Available

When 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:

  1. Open the package.json of your project
  2. Add the following example to it:
// package.json
"prisma": {
  "seed": "ts-node prisma/seed.ts"
}
Expand to view an example seed script
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 Generally Available

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.

Order by Aggregate in Group By is Generally Available

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',
    },
  },
}),
Expand to view the underlying Prisma schema
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.

Order by Relation is Generally Available

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,
  },
})
Expand to view the underlying Prisma schema
```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 is Generally Available

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 },
    },
  },
})
Expand to view the structure of the returned `users` ```ts [ { id: 2, email: '[email protected]', city: 'London', name: 'Bob', _count: { posts: 2 }, }, { id: 1, email: '[email protected]', city: 'Berlin', name: 'Alice', _count: { posts: 1 }, }, ] ```

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.

Breaking Changes

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.

Named Constraints

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. ⚠️

Referential Actions

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.

Seeding with 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:

  • Add the script to prisma.seed in your package.json
  • Adapt the script to the new API.

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 changes

We’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:

  1. Tagged Template: prisma.$queryRaw...``. This API sent a prepared statement and was safe from SQL injections.
  2. Function Call: 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":

  1. $queryRaw...``: Safe from SQL injections. Sends a prepared statement and returns the resulting rows.
  2. $executeRaw...``: Safe from SQL injections. Sends a prepared statement and returns the result count.
  3. $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.
  4. $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.

Changes to how you query Null values on JSON fields

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:

  • JsonNull: Selects the null value in JSON.
  • DbNull: Selects the NULL value in the database.
  • AnyNull: Selects both null JSON values and NULL database values.

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,
      },
    },
  },
})

Learn more about JSON filtering in our documentation.

Renamed Aggregate Fields

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.

The minimum required version of Node.js is v12.6

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.

Fixes and improvements
Prisma Migrate
Prisma Client
Prisma
Language tools (e.g. VS Code)
Prisma Studio
Credits

Huge thanks to @​saintmalik, @​benkenawell, @​ShubhankarKG, @​hehex9 for helping!

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

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.

v2.30.3

Compare Source

Today, we are issuing the 2.30.3 patch release.

Improvements
Prisma CLI
Fixes
Prisma Studio

v2.30.2

Today, we are issuing the 2.30.2 patch release.

Fixes
Prisma Client

v2.30.0

Compare Source

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. 🌟 

New features & improvements
Full-Text Search for PostgreSQL is now in Preview 🚀

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.

Validation errors for referential action cycles on Microsoft SQL Server ℹ

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.

Prisma Adopts Semantic Versioning (SemVer)

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.

Fixes and improvements
Prisma Client
Prisma Migrate
Language tools (e.g. VS Code)
@​prisma/engines npm package
Credits

Huge thanks to @​saintmalik for helping!

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

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

The stream takes place on Youtube on Thursday, August 26 at 5pm Berlin | 8am San Francisco.

v2.29.1

Compare Source

Today, we are issuing the 2.29.1 patch release.

Fixes
Prisma Client

v2.29.0

Compare Source

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. 🌟

Major improvements & new features
Interactive Transactions are now in Preview

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 are now in Preview

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.

The 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 and map 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.

Prisma Adopts Semantic Versioning (SemVer)

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.

Fixes and improvements
Prisma Client
Prisma Migrate
Credits

Huge thanks to @​benkenawell for helping!

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

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

The stream takes place on Youtube on Thursday, March 04 at 5pm Berlin | 8am San Francisco.

v2.28.0

Compare Source

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. 🌟 

MongoDB improvements 🚀

Thanks to your feedback, we fixed a handful of bugs reported on the MongoDB connector (Preview):

  • Concurrent findUnique queries leading to an error #​8276
  • Filtering by relations wasn't working properly #​7057
  • Filtering on an array of IDs #​6998

Please keep reporting issues to our team and help to bring MongoDB support closer to GA!

Prisma Adopts Semantic Versioning (SemVer)

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.

Create new Prisma projects in under 3 minutes ⏳

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:

  • Explore data in the database using the data browser.
  • Add other users to it, such as your teammates or your clients.
  • Assign users one of four roles: Admin, Developer, Collaborator, Viewer.
  • View and edit your data collaboratively online.

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:

  • Choose a Prisma schema from a selection of our templates.
  • Create a free PostgreSQL database on Heroku.
  • Populate the database with seed data.

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.

Quick overview

If you have a Heroku account, we can create a free Postgres database for you:

Prisma cloud onboarding

Start your project with a schema from our templates:

schema_templates

Interested in Prisma’s upcoming Data Proxy for serverless backends? Get notified! 👀

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

Fixes and improvements
Prisma Client
Prisma Migrate
Prisma Studio
Credits

Huge thanks to @​ShubhankarKG, @​hehex9 for helping!

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

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

The stream takes place on Youtube on Thursday, July 15 at 5pm Berlin | 8am San Francisco.

v2.27.0

Compare Source

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. 🌟 

Major improvements & new features
MongoDB is Now in Preview 🎉

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>@&#8203;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 "@&#8203;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.

Prisma native support for M1 Macs 🚀

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!

Fixes and improvements
Prisma Client

Configuration

📅 Schedule: "before 7am on Tuesday" in timezone Australia/Sydney.

🚦 Automerge: Disabled by config. Please merge this manually once you are satisfied.

Rebasing: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox.

🔕 Ignore: Close this PR and you won't be reminded about these updates again.


  • If you want to rebase/retry this PR, check this box.

This PR has been generated by WhiteSource Renovate. View repository job log here.

@changeset-bot
Copy link

changeset-bot bot commented Sep 13, 2021

⚠️ No Changeset found

Latest commit: 3ae8e37

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@bladey bladey closed this Sep 30, 2021
@renovate
Copy link
Contributor Author

renovate bot commented Sep 30, 2021

Renovate Ignore Notification

As this PR has been closed unmerged, Renovate will ignore this upgrade and you will not receive PRs for any future 3.x releases. However, if you upgrade to 3.x manually then Renovate will reenable minor and patch updates automatically.

If this PR was closed by mistake or you changed your mind, you can simply rename this PR and you will soon get a fresh replacement PR opened.

@renovate renovate bot deleted the renovate/major-prisma-monorepo branch September 30, 2021 01:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants