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

[legacy-framework] Upgrade @prisma/cli: 2.10.0 → 2.12.0 (example) #1523

Merged
merged 1 commit into from Nov 24, 2020

Conversation

depfu[bot]
Copy link

@depfu depfu bot commented Nov 24, 2020

Here is everything you need to know about this upgrade. Please take a good look at what changed and the test results before merging this pull request.

What changed?

✳️ @​prisma/cli (2.10.0 → 2.12.0) · Repo

Release Notes

2.12.0

Today, we are excited to share the 2.12.0 stable release 🎉

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

Major improvements

Prisma codemods help upgrading your codebase

With today's release, we took the opportunity to cleanup some rough edges in the Prisma Client API which partially results in breaking changes. To help you with upgrading your codebase to 2.12.0, we're introducing @prisma/codemods.

The @prisma/codemods package provides a powerful CLI that scans your codebase and automatically updates the code to the new API calls from the provided version.

The upgrade workflow looks like this:

cd my-app
npm install @prisma/cli @prisma/client
npx @prisma/codemods update-2.12 ./

Microsoft SQL Server now supports native database types (Preview)

Hot off the presses: You can now use database native types with Microsoft SQL Server! You'll need to specify both previewFeatures = ["microsoftSqlServer", "nativeTypes"] to get started:

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

datasource ms {
provider = "sqlserver"
url = env("DATABASE_URL")
}

model User {
id BigInt @id @default(autoincrement()) @ms.BigInt
name String? @ms.VarChar(255)
}

model Post {
id BigInt @id @default(autoincrement()) @ms.BigInt
title String @ms.VarChar(100)
views BigInt @default(0) @ms.BigInt
wordCount Int @default(0) @ms.SmallInt
}

Note that Prisma Migrate does not yet work with Microsoft SQL Server, nor does Prisma Client Go.

Upcoming Prisma Migrate Preview Release

We’ve got a Preview release of Prisma Migrate nearing up with a large set of changes. You can test it in Early Access, see the upcoming changes, and provide feedback! Get started with the Early Access version here.

To join the conversation, join the #product-feedback channel on our Slack.

Breaking changes

As mentioned before, we're cleaning up the Prisma Client API which partially results in breaking changes. You can upgrade to the latest version using the new @prisma/codemods package as explained above.

Remove non-$ methods

A few months back, we began prefixing our top-level Prisma methods with $. For example, prisma.transaction became prisma.$transaction. We did this to avoid clashes with your application's model names.

The non-$ methods were deprecated but continued to work until this release. In this release, we removed the deprecated methods.

This means if you are still using calls like prisma.transaction or prisma.disconnect instead of prisma.$transaction or prisma.$disconnect in your code, your app is going to break after upgrading to 2.12.0.

The @prisma/codemods workflow describe above will automatically fix any remaining non-$ methods in your codebase.

You can read more about this change in on Github.

1-1-relations must now have an optional side

In this version, we're adding a new requirement for 1-1-relations that you define in your Prisma schema. In previous versions, it used to be allowed to have both sides of the relation required. As of this release, the virtual side of the relation (i.e. the side that does not store the foreign key in the underlying database) must be optional.

Before

model User {
  id      Int      @id @default(autoincrement())
  name    String?
  profile Profile  // ❌ this is not allowed as of 2.12.0
}

model Profile {
id Int @id @default(autoincrement())
user User @relation(fields: [userId], references: [id])
userId Int
}

After

model User {
  id      Int      @id @default(autoincrement())
  profile Profile? // ✅ the virtual side of the relation needs to be optional
}

model Profile {
id Int @id @default(autoincrement())
user User @relation(fields: [userId], references: [id])
userId Int
}

The easiest way to adjust your schema to these new requirements is by running the introspect command which will automatically make the virtual relation fields optional on 1-1-relations:

npx prisma introspect

Fix how data for Json[] fields is stored

We fixed how the Json[] type is stored in 2.12.0. Previously, we were storing JSON arrays as a string inside a your database's JSON column. Now, we properly encode JSON arrays as JSON in the database. This fix will allow us to add database native JSON operations down the line.

If you are using the Json[] type in your schema, you'll need to migrate your data. We anticipate this breaking change will only affect a handful of folks. Please reach out to us in this issue and we'll help you with the migration.

Here is an overview of how the behaviour changes in 2.12.0:

Given 2.11.0 2.12.0
[] [[]] []
[{test:"test"}] ["{\"test\":\"test\"}"] [{"test":"test"}]
[{ test: "test" }, { test: "test2" }] ["[{\"test\": \"test\"}, {\"test\": \"test2\"}]"] [{"test": "test"},{"test": "test2"}]
[3] 3 [3]

Deprecations

Rename findOne to findUnique

This release renames findOne to findUnique and deprecates findOne.

We made this change to reduce confusion. Many people expected findOne to be more loose, e.g: "Find the first record that matches my conditions.".

The @prisma/codemods workflow describe above will automatically rename findOne to findUnique across your codebase.

Move most types under the Prisma namespace

We moved most of the generated types under a new Prisma namespace and are deprecating the top-level exports. This change also resolves some existing namespace clashes.

Before

import { PrismaClient, User, UserCreateInput } from '@prisma/client'

async function createUser(input: UserCreateInput): Promise<User> {
return prisma.user.create(input)
}

After

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

async function createUser(input: Prisma.UserCreateInput): Promise<User> {
return prisma.user.create(input)
}

This means that with this release, there are exactly three kinds of exports in @prisma/client:

  1. PrismaClient is the constructor your Prisma Client instance
  2. Model types, e.g. User and Post
  3. Prisma as the new namespace under which you can now access the remaining generarted types

The @prisma/codemods workflow describe above will automatically fix the type names in your code!

With this change, we've greatly reduced the number of reserved words that could clash with your application's names. Go forth and add models with names like Transaction or Aggregate!

Fixes and improvements

prisma

prisma-client-js

migrate

language-tools

studio

prisma-engines

Credits

Huge thanks to @matt-eric, @muxahuk for helping!

2.11.0

Today, we are excited to share the 2.11.0 stable release 🎉

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

Major Improvements

Native database types in the Prisma schema (Preview)

We are super excited to share that this release brings you one of the most requested features since we released the initial version of Prisma: The representation of native database types in the Prisma schema.

Up to this release, the Prisma schema only allowed to represent a limited set of types: String, Int, Float, Boolean, DateTime, Json. Each of these types has a default mapping to an underlying database type that's specified for each connector (see the mappings for PostgreSQL and MySQL).

With this release, you can now add an attribute to a field definition in order to determine which specific database type it should be mapped to. Here is an example for a PostgreSQL database that specifies the underlying database types more specifically. Note that you also need to enable the feature via the the nativeTypes feature flag:

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

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

model User {
id Int @id @default(autoincrement())
name String? @db.VarChar(255)
}

model Post {
id Int @id @default(autoincrement())
title String @db.VarChar(100)
createdAt DateTime @db.Timestamp(6)
wordCount Int @db.SmallInt
}

In the above code snippet, all fields of the two Prisma models are annotated with attributes to diverge from the default mapping and determine the exact type that is used in the underlying database. For example, the id fields are represented as db.BigInt which maps to the BIGINT PostgreSQL type. You can find out more about which Prisma types can be annotated with which native type attributes in the docs for the PostgreSQL and MySQL connectors.

Please share your feedback on how this feature works for you. We are interested in both positive and negative feedback, so we know if this feature is already ready for production! (If encounter any problems, please open a new issue here).

📚 Documentation: Extended native type support

New types in the Prisma schema: BigInt, Bytes and Decimal (Preview)

With this release, we are further introducing three new scalar types in the Prisma schema: BigInt, Bytes and Decimal. Here is an overview for how they map to the different databases that are supported by Prisma and how they're represented when queried with Prisma Client JS:

Prisma PostgreSQL MySQL SQLite JavaScript / TypeScript
Bytes BYTEA LONGBLOB n/a Buffer
Decimal DECIMAL(65,30) DECIMAL(65,30) n/a Decimal.js
BigInt BIGINT BIGINT n/a BigInt

To make use of these new types, you need to enable the nativeTypes feature flag in your Prisma schema:

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

Once you added the feature flag, be sure to run prisma generate again to update your local version of Prisma Client.

📚 Documentation: Prisma types in the nativeTypes preview

Set foreign keys directly (Preview)

We now support writing foreign keys (also known as relation scalars) directly with the uncheckedScalarInputs preview feature.

Consider this sample Prisma schema:

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

model User {
id Int @id @default(autoincrement())
posts Post[]
}

model Post {
id Int @id @default(autoincrement())
authorId Int
author User @relation(fields: [authorId], references: [id])
}

Instead of using connect when creating a new Post record to wire up a relation with a User record, you can now directly set the authorId value:

await prisma.post.create({
  data: {
    // You can now set the foreign key directly...
    authorId: 1,
    // ... or connect the relationship...
    // author: {
    //   connect: {
    //     id: 1
    //   }
    // }
    // ... but not both at the same time
  },
});

We'd love for you to give it a try. You can give us feedback in this issue.

The $transaction API is now stable

You can now use $transaction API without the transactionApi feature flag.

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

The connectOrCreate API is now stable

The connectOrCreate API offers a convenient way to link or insert nested records.

You can now use it without the connectOrCreate feature flag.

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

Middleware model parameter is now typed

This is a small quality-of-life improvement for developers using the Prisma middleware. The params.model parameter that's passed into a middleware function is now typed to your model so you can now reliably tie middleware to models:

prisma.$use(async (params, next) => {
  switch (params.model) {
    case 'user':
      // ...
    case 'project:
      // ...
  }
})

If you need the old behavior you can cast params.model back to a string by wrapping it String(params.model).

📚 Documentation: Middleware

Deprecation of multi-provider array

You will now see a warning if you have multiple providers in your datasource. We recently realized that supporting an array of providers in the Prisma schema was premature, adding complexity in the process of improving the product, and causing some confusion about our intent.

You can read more about the decision and what to do about it in this issue.

Validate PrismaClient inputs at runtime

We now validate the parameters we accept in new PrismaClient(parameters). This is unlikely to affect you unless you were passing invalid parameters into PrismaClient before.

Prisma Client Go is now Early Access 🎉

We're happy to announce that Prisma Client Go has graduated from experimental to Early Access.

You can get started here. We'd love to learn more about how you use the Go Client during Early Access. You can schedule a call with us or chat with us on Slack in the #prisma-client-go channel. We're looking forward to hearing from you!

📺 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, November 12 at 5pm Berlin | 8am San Francisco.

👀 Make your online talk recordings more accessible with subtitles

We'd love to help you make your talk recordings (no matter if Meetup or conference talk) more accessible by adding subtitles to it for free! Reach out to sponsorships@prisma.io if you are interested in getting subtitles for your videos!

Fixes and improvements

prisma

prisma-client-js

language-tools

studio

prisma-engines

2.10.2

Today, we are issuing the 2.10.2 patch release.

Fixes

Client

Language Tools

2.10.1

Today, we are issuing the 2.10.1 patch release.

Fixes

CLI

Client

Migrate

Language Tools

Does any of this look wrong? Please let us know.

Commits

See the full diff on Github. The new version differs by more commits than we can show here.

✳️ jest (24.9.0 → 26.5.3) · Repo · Changelog

Release Notes

Too many releases to show here. View the full release notes.

Commits

See the full diff on Github. The new version differs by more commits than we can show here.

✳️ ts-jest (24.3.0 → 26.4.1) · Repo · Changelog

Release Notes

Too many releases to show here. View the full release notes.

Commits

See the full diff on Github. The new version differs by more commits than we can show here.


Depfu Status

Depfu will automatically keep this PR conflict-free, as long as you don't add any commits to this branch yourself. You can also trigger a rebase manually by commenting with @depfu rebase.

All Depfu comment commands
@​depfu rebase
Rebases against your default branch and redoes this update
@​depfu recreate
Recreates this PR, overwriting any edits that you've made to it
@​depfu merge
Merges this PR once your tests are passing and conflicts are resolved
@​depfu close
Closes this PR and deletes the branch
@​depfu reopen
Restores the branch and reopens this PR (if it's closed)
@​depfu pause
Ignores all future updates for this dependency and closes this PR
@​depfu pause [minor|major]
Ignores all future minor/major updates for this dependency and closes this PR
@​depfu resume
Future versions of this dependency will create PRs again (leaves this PR as is)

@depfu depfu bot requested review from aem and flybayer as code owners November 24, 2020 14:51
@depfu depfu bot added the depfu label Nov 24, 2020
@blitzjs-bot blitzjs-bot bot added this to In Review in Dashboard Nov 24, 2020
@github-actions
Copy link
Contributor

Size Change: 0 B

Total Size: 195 kB

ℹ️ View Unchanged
Filename Size Change
packages/blitz/dist/cli.js 15.7 kB 0 B
packages/blitz/dist/index.js 245 B 0 B
packages/config/dist/config.cjs.development.js 1.35 kB 0 B
packages/config/dist/config.cjs.production.min.js 917 B 0 B
packages/config/dist/config.esm.js 1.28 kB 0 B
packages/config/dist/index.js 143 B 0 B
packages/core/dist/core.cjs.development.js 12.9 kB 0 B
packages/core/dist/core.cjs.production.min.js 6.99 kB 0 B
packages/core/dist/core.esm.js 12.5 kB 0 B
packages/core/dist/index.js 141 B 0 B
packages/display/dist/display.cjs.development.js 1.43 kB 0 B
packages/display/dist/display.cjs.production.min.js 819 B 0 B
packages/display/dist/display.esm.js 1.33 kB 0 B
packages/display/dist/index.js 144 B 0 B
packages/file-pipeline/dist/file-pipeline.cjs.development.js 5.9 kB 0 B
packages/file-pipeline/dist/file-pipeline.cjs.production.min.js 3.02 kB 0 B
packages/file-pipeline/dist/file-pipeline.esm.js 5.76 kB 0 B
packages/file-pipeline/dist/index.js 147 B 0 B
packages/generator/dist/generator.cjs.development.js 15.6 kB 0 B
packages/generator/dist/generator.cjs.production.min.js 9.47 kB 0 B
packages/generator/dist/generator.esm.js 15.3 kB 0 B
packages/generator/dist/index.js 145 B 0 B
packages/generator/dist/templates/app/babel.config.js 77 B 0 B
packages/generator/dist/templates/app/blitz.config.js 324 B 0 B
packages/generator/dist/templates/app/jest.config.js 682 B 0 B
packages/generator/dist/templates/app/test/__mocks__/fileMock.js 54 B 0 B
packages/installer/dist/index.js 145 B 0 B
packages/installer/dist/installer.cjs.development.js 7.69 kB 0 B
packages/installer/dist/installer.cjs.production.min.js 5.14 kB 0 B
packages/installer/dist/installer.esm.js 7.54 kB 0 B
packages/repl/dist/index.js 141 B 0 B
packages/repl/dist/repl.cjs.development.js 1.81 kB 0 B
packages/repl/dist/repl.cjs.production.min.js 1.08 kB 0 B
packages/repl/dist/repl.esm.js 1.69 kB 0 B
packages/server/dist/index.js 142 B 0 B
packages/server/dist/server.cjs.development.js 22.2 kB 0 B
packages/server/dist/server.cjs.production.min.js 12.7 kB 0 B
packages/server/dist/server.esm.js 22.3 kB 0 B

compressed-size-action

@flybayer flybayer added the 0 - <(^_^)> - merge it! ✌️ Kodiak automerge label Nov 24, 2020
@depfu
Copy link
Author

depfu bot commented Nov 24, 2020

Sorry, but the merge failed with:

You're not authorized to push to this branch. Visit https://docs.github.com/articles/about-protected-branches/ for more information.

@flybayer flybayer changed the title Upgrade @prisma/cli: 2.10.0 → 2.12.0 (minor) Upgrade @prisma/cli: 2.10.0 → 2.12.0 (example) Nov 24, 2020
@flybayer flybayer merged commit f96bcb8 into canary Nov 24, 2020
Dashboard automation moved this from In Review to Done Nov 24, 2020
@flybayer flybayer deleted the depfu/update/yarn/@prisma/cli-2.12.0 branch November 24, 2020 15:18
@dillondotzip dillondotzip changed the title Upgrade @prisma/cli: 2.10.0 → 2.12.0 (example) [legacy-framework] Upgrade @prisma/cli: 2.10.0 → 2.12.0 (example) Jul 7, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
No open projects
Development

Successfully merging this pull request may close these issues.

None yet

1 participant