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. usingTRUNCATE _Migration;
Fixes and improvements per Prisma Framework repository
prisma2
- Document unix socket usuage
lift up
not applying migrations to fresh database, whilstprisma2 dev
does?- Introspection panic on a non empty database
- Introspection panics on an empty database
- Prisma 2 init with SQLite works but throws an error
- prisma2 init crashing
- Document multiple default(now()) restrictions
- [Introspection] Panic: FK to non existent table
- [Introspection] Remove @default from scalar lists
- [Introspection] PrismaModels should be able to handle relation field as Id
- Could not install prisma2 using volta
- Lift and dev, popup to create a new database missing
- Automatically clean prisma2 binary cache
- Rust panic with Chinook and SQLite
- Improve install behavior on linux
- prisma2 dev cannot find heroku postgres database
- Existing database with MySQL doesn't print
- Error in migration engine when using with sample Chinook dataset
- Make error text more helpful
- [Docs] Query Builder
- Error: Unknown database type postgres:
- Unix socket connection not working
prisma2
commands could fail more gracefully when query and migration engine are not present- Consistent binary names
photonjs
- Photon's error improvement on missing binary
- Photon facade with netlify
- Photon facade with zeit now
- Document Photon and environment variables behavior
- Make prisma2 an optional peer dependency
- @prisma/photon installation hangs
- PhotonJS fails to load environment variables from env file
- Multiple calls to disconnect should be noops
- Invalid
ctx.photon.posts.create()
invocation - Regenerating Photon causes API in development to crash
lift
- Lift is trying to recreate type aliases
- Migration Readme Incorrect
- Update printMigrationReadme.ts
- support <inc|name|timestamp> in up/down cli