github prisma/prisma 2.0.0-preview015

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

Today, we are issuing the fifteenth Preview release: 2.0.0-preview015 (short: preview015).

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

Major changes

Lift now features an explicit UI that warns about destructive changes before performing a schema migration: (Right now column and table dropping are recognized)

Screenshot 2019-10-22 at 16 19 26

Breaking changes

Photon.js now maps DateTime from the Prisma schema to Date in JavaScript

Assume you have the following Prisma model:

model Post {
  id        String   @default(cuid()) @id @unique
  createdAt DateTime @default(now())
  updatedAt DateTime @updatedAt
  title     String
}

The Photon.js generator now sets the types of the createdAt and updatedAt fields to Date instead of string:

export declare type Post = {
    id: string;
    createdAt: Date;
    updatedAt: Date;
    title: string;
}

findOne doesn't throw any more but has optional return type

Based on this issue, we decided to adjust the Photon.js API for findOne calls. Instead of throwing an exception when there is no record that meets the specified where condition for a findOne call, it now returns null.

Assume again the same Prisma model as before:

model Post {
  id        String   @default(cuid()) @id @unique
  createdAt DateTime @default(now())
  updatedAt DateTime @updatedAt
  title     String
}

So, in your application code you might want to adjust the catch calls to explicit checks for null:

Before

try {
  const post = await photon.posts.findOne({
    where: { id }
  })
  // ... do something with `post`
} catch(e) {
  console.log(`Did not find record with ID: ${id}`)
}

After

const post = await photon.posts.findOne({
  where: { id }
})
if (post === null) {
  console.log(`Did not find record with ID: ${id}`)
  return
}
// ... do something with `post`

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.