github prisma/prisma 2.0.0-preview019

latest releases: 5.13.0, 5.12.1, 5.12.0...
pre-release4 years ago

Today, we are issuing the nineteenth Preview release: 2.0.0-preview019 (short: preview019). In case you've missed it, you can read about the current state of Prisma 2 on our blog.

This release has a number of breaking changes, be sure to read the notes below before upgrading!
You can find a full upgrade guide here.

Note that we recently adjusted the versioning schema in order to fully comply to the semver spec (the first release with the new version schema was 2.0.0-preview014).

Breaking changes

Support for native scalar lists (arrays) in the Prisma schema

Prisma's scalar list support for MySQL and SQLite is removed in this version. For PostgreSQL, Prisma is now mapping scalar lists in the Prisma schema to PostgreSQL arrays.

Here is an example of a native scalar list (of type boolean) in the Prisma schema:

model User {
  id        Int       @id
  name      String    @default("")
  coinflips Boolean[]
}

You can find the workflows for upgrading Prisma for your database here.

Make ID handling for Int and String consistent

Previously, the way how Prisma handled IDs was a bit inconsistent. For example, this was allowed:

model User {
  id Int @id
}

But this wasn't:

model User {
  id String @id
}

There was a difference in how Prisma handled IDs of type String and type Int.

In the first case, Prisma added the behaviour of auto-incrementing IDs (i.e. IDs received a default value), so it wasn't required to provide an id value when new User records were created via the generated Photon.js API.

The same User model with id field of type Int now will not receive any default, auto-incrementing values for id any more. Instead id values must be explicitly provided when creating new User records via Photon.js:

// Before, this was possible
const user = await photon.users.create()

// Now you need to provide an `id`
const user = await photon.users.create({
  data: {
    id: 42
  }
})

In most cases, you'll want to retain the previous functionality though. To get this functionality, you need to add the @default(autoincrement()) to the id field:

model User {
  id Int @id @default(autoincrement())
}

Disallow @id and @unique on the same field

Previously it was possible to add @unique attribute to a field that was already annotated with @id:

model User {
  id Int @id @unique
}

This is now forbidden since uniqueness is already implied by @id:

model User {
  id Int @id
}

Breaking change in Lift migrations

This release contains a breaking change to the way how Lift stores the migration history. In order to use Lift with the newest version, you have to:

  • manually delete the migrations folder from the file system
  • truncate or delete Lift's _Migrations table, e.g. using TRUNCATE _Migration;

Fixes and improvements per Prisma Framework repository

prisma2

photonjs

lift

prisma-engine

Don't miss a new prisma release

NewReleases is sending notifications on new releases.