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)
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
- Cursor does not work in
alpha.241
- Docs: Please document how to handle DateTime values with Photon.js
- More inclusive language in docs
- Telemetry: Error report ID
- Postgres: A database with that name doesn't exist at xx.xx.xx.xx using @2.0.0-preview013.3
init
flow doesn't show instruction to navigate into new directory- fix: prisma2 introspect for mysql database
prisma2 dev
: Asks to save changes into a migration file by runningprisma2 lift save
but givesEverything up-to-date
in terminal- Telemetry prompt options don't work on Windows (cursor keys do nothing)
- Limitations: nested write vs. nested mutations
- Conflicting "Make sure to adjust the generator configuration in the schema.prisma file:" error message
- [Windows]
prisma2 init
fails withError: Can't find Python executable "python", you can set the PYTHON env variable.
photonjs
- DateTime should be mapped to Date
.count()
returnsnull
for empty tables- Select in finds methods optional fields
- findOne: Stop throwing an error when no record found
- Possibly wrong type generation for
after
argument in findMany method (Postgres) Field does not exist on enclosing type.
When using most filters (some, etc)