Today, we are issuing the twenty-second Preview release: 2.0.0-preview022
(short: preview022
).
This release contains breaking changes, be sure to read the notes below before upgrading!
Major improvements
- Send raw SQL queries using
prisma.raw(sql)
(read the API docs) - Stopped shipping TypeScript with Prisma Client JS
- Various introspection improvements
prisma2 init
now uses environment variables and creates a.env
file
Breaking changes
Remove pluralization of virtual back-relation fields
The following change is only breaking if you're using introspection and are currently using Prisma Client API calls that are referencing a virtual back-relation field. Read on to learn more.
When introspecting a table with a foreign key, Prisma automatically creates a "virtual back-relation" field on the respective Prisma model. Consider the following SQL schema:
CREATE TABLE User (
user_id SERIAL PRIMARY KEY NOT NULL,
name VARCHAR(256),
);
CREATE TABLE Post (
post_id SERIAL PRIMARY KEY NOT NULL,
title VARCHAR(256) NOT NULL,
author_id INTEGER,
FOREIGN KEY (author_id) REFERENCES User(user_id)
);
In previous Prisma 2 preview versions, the resulting Prisma data model after introspection used to be:
model User {
user_id Int @id @default(autoincrement())
posts Post[] // before `preview022`
}
model Post {
post_id Int @id @default(autoincrement())
title String
author User?
}
Notice the posts
field which has been added by Prisma. This field does not exist as a column on the database-level, but is a "virtual back-relation" field in the Prisma schema.
With preview022
, the pluralization of the virtual back-relation field has been removed. The new introspection result would be:
model User {
user_id Int @id @default(autoincrement())
post Post[] // after `preview022`
}
model Post {
post_id Int @id @default(autoincrement())
title String
author User?
}
Path for default .env
file changed
As explained in this issue, the path to the default .env
file is changed in this Preview version. Before, the Prisma CLI automatically loaded the environment variables from a .env
file in the current working directory. This now changes and it only loads them from the directory that contains the schema.prisma
file.
Enums are now handled natively (Prisma Migrate)
Enums in the Prisma schema are now mapped to enums in the underlying database (previously they were represented as strings). This means enum support for SQLite is completely removed since SQLite doesn't support enums.
Fixes and improvements per Prisma 2 repository
prisma2
- Implement changes from CLI spec
- Environment variable not found on latest alpha release
warning In order to use "@prisma/client", please install prisma2. You can install it with "npm add -D prisma2"
is printed even when prisma2 is installed- Fetch binaries from domain instead of direct s3 url
- Implement new init flow spec
- [Introspection] Change work distribution between CLI and Introspection Engine
- Document
.raw
API - Download prints many empty lines
- Improve DX about --experimental CLI commands
- Use anonymous machine token from checkpoint for error reporting
@prisma/client@x is not compatible with prisma2@y. Their versions need to be equal.
, generates anyway- Introspection: Don't execute
getDatabaseDescription
if error consent screen didn't have confirmation - Only support
.env
file next toschema.prisma
- [Introspection] No ID: Why does it sometimes error and sometimes panic?
- [Introspection]
@@id
refers to original field name instead of@map
-ped one - Introspection Error Reporting does not output report ID
introspect
: "Error [ERR_STREAM_DESTROYED]: Cannot call write after a stream was destroyed"- MySQL datamodel not matching prisma2 introspect generated schema
generate
: "Error: Schema parsing --- thread 'main' has overflowed its stack"- Native Enums only
- [Introspection] Investigate and improve introspection speed
- Improve error when
id
is a String in the schema but an Integer in SQLite. - Make using DATABASE_URL as default DB connection URL a best practice
- Init flow should default to using environment variables for connection URLs
- Create "Getting started" escape hatch for non-existent databases
- Change default schema.prisma
- Migration guide missing from Getting Started
- Improve SSL connection docs
- Empty Introspection result could lead to much nicer error message and explanation
- Supply a custom path to Prisma schema file for CLI commands (i.e.
--schema
?) - Improve
introspect
command, backup behavior - Unclear Introspection error message: Error parsing attribute "@id": Fields that are marked as id must be required.
- [Introspection] Additionally output count of error at end of validation output
- [Introspection] Better handling of "Error: Empty introspection result for ..."
- [Introspection] "error: Field 'x' is already defined on model 'y'.", relation name clashes
- [Introspection] "No id field defined!" should not panic and crash, but just output an error
- [Introspection] posts are turned into postses
- [Introspection] Panic "No id field defined!" (caused by: no id at all)
- Inconsistent engine files names
- Introspection tells me
⠋ Introspecting MySQL schema with 1 tables.
during introspection Upsert
causes random self-referencing 1:1 relations to break
prisma-client-js
- SQLite: Tokio stack overflow for a lot of data
- Remove compatibility plural api
- Unclear error when we guess a binary
- Execute raw is failing when template literal span over multiple lines.
- Cannot read property 'plural' of undefined at PrismaClientClass.get jsDoc
- Implement
nextTick
- based batching - Postinstall:
undefined
and Error generate
tells me to install wrong Prisma Client package- Add JSDoc to top-level argument types
- .raw(...) query
- Prisma Client should pick up required env vars from .env file during development
- Make "unnecessary" client properties private
- Database restart not handled gracefully
- AWS LAMBDA - Invalid photon.() EROFS: read-only file system, chmod '/var/task/.../query-engine-rhel-openssl-1.0.x'
- Duplicate
null
in ENUM filters - Stub types should be included in the released package
- UUID joins not working after 0.20 upgrade
- Document Timeouts in Prisma Client for high parallel usage
- Do not mutate exports.dmmf in generated Prisma Client
- Stop shipping TypeScript
- Expose a utility TS type to be able to extract the return type for model expressions with includes
- Bad enum naming cause Prisma Client generation error in index.d.ts
- Bundlers and binary as static assets
migrate
- Wrong name in error message
--help
does not need--experimental
for mainmigrate
, does formigrate save