Prisma: 2.0.0-preview022 Release

Release date:
February 18, 2020
Previous version:
2.0.0-preview021 (released January 30, 2020)
Magnitude:
3,856 Diff Delta
Contributors:
11 total committers
Data confidence:
Commits:

96 Commits in this Release

Ordered by the degree to which they evolved the repo in this version.

Authored February 13, 2020
Authored February 10, 2020
Authored February 13, 2020
Authored February 17, 2020
Authored February 12, 2020
Authored February 3, 2020
Authored February 14, 2020
Authored February 12, 2020
Authored February 12, 2020
Authored February 12, 2020
Authored February 12, 2020
Authored February 5, 2020
Authored February 4, 2020
Authored February 3, 2020
Authored February 17, 2020
Authored January 30, 2020
Authored February 13, 2020
Authored February 4, 2020
Authored February 7, 2020
Authored February 13, 2020
Authored February 12, 2020
Authored February 4, 2020
Authored February 14, 2020
Authored February 17, 2020
Authored February 7, 2020
Authored February 14, 2020
Authored February 5, 2020
Authored February 10, 2020
Authored February 7, 2020
Authored February 6, 2020
Authored February 18, 2020

Top Contributors in 2.0.0-preview022

matthewmueller
Jolg42
nikolasburk
timsuchanek
robin-macpherson
SaiNageswarS
mikemaccana
RafaelKr
ieschalier
atjeff

Directory Browser for 2.0.0-preview022

We haven't yet finished calculating and confirming the files and directories changed in this release. Please check back soon.

Release Notes Published

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

prisma-client-js

migrate

prisma-engines