prisma

Next-generation ORM for Node.js & TypeScript | PostgreSQL, MySQL, MariaDB, SQL Server, SQLite, MongoDB and CockroachDB

APACHE-2.0 License

Downloads
64.3M
Stars
39.2K
Committers
259

Bot releases are hidden (Show)

prisma - 2.0.0-preview020.3

Published by timsuchanek over 4 years ago

prisma - 2.0.0-preview020

Published by nikolasburk over 4 years ago

Today, we are issuing the twentieth Preview release: 2.0.0-preview020 (short: preview020).

This release has a number of major and breaking changes, be sure to read the notes below before upgrading!

The most important changes are:

  • Renamed Photon.js to Prisma Client JS (or just Prisma Client)
  • Renamed Lift to Prisma Migrate
  • Moved Prisma's migrate (formerly lift) subcommands behind an --experimental flag
  • Removed the prisma2 dev command
  • Removed the interactive prisma2 init wizard
  • Introduced a new telemetry endpoint
  • Renamed notion of Prisma Framework back to Prisma 2
  • onDelete has been removed from the @relation attribute

To see how the changes affect an application, check out the updated examples.

⚠️ If you're using Prisma together with GraphQL Nexus and nexus-prisma, check out the additional release notes of nexus-prisma: https://github.com/prisma-labs/nexus-prisma/releases/tag/0.7.0

Breaking changes

Photon.js has been renamed to Prisma Client JS

Aside from the renaming throughout all our content resources, this change is breaking the generator definition in your Prisma schema. Instead of using photonjs as the provider of your generator, you now need to use prisma-client-js:

generator client {
-  provider = "photonjs"
+  provider = "prisma-client-js"
}

The Prisma Client's npm package has also been renamed. Instead of installing @prisma/photon, you're now using @prisma/client:

- npm install @prisma/photon
+ npm install @prisma/client

Finally, the way how you import Prisma Client in your code and instantiate it needs to be adjusted too:

- import { Photon } from '@prisma/photon'
+ import { PrismaClient } from '@prisma/client'
+ // const { PrismaClient } = require('@prisma/client')

- const photon = new Photon
+ const prisma = new PrismaClient()

Note that the former photonjs repo is now called prisma-client-js. We also removed the former Photon.js website on https://photonjs.prisma.io and are redirecting it to these release notes.

We renamed Photon.js in an effort to make Prisma simpler. Instead of using abstract names for the Prisma tools, we've decided to use descriptive names for the different parts of Prisma to make it easier for newcomers to understand what each of our tools does.

Lift has been renamed to Prisma Migrate and is now behind an --experimental flag

Prisma's lift subcommand has been renamed to migrate:

- prisma2 lift save
- prisma2 lift up
+ prisma2 migrate save
+ prisma2 migrate up

The initial launch of Prisma 2 in February will include only Prisma Client, but not yet Prisma's migration tooling. To anticipate this split, all migration-related functionality of the prisma2 CLI now requires an explicit opt-in via an --experimental flag:

prisma2 migrate save --experimental
prisma2 migrate up --experimental

Note that the former lift repo is now called migrate. We also removed the former Lift website on https://lift.prisma.io and are redirecting it to these release notes.

We renamed Lift in an effort to make Prisma simpler. Instead of using abstract names for the Prisma tools, we've decided to use descriptive names for the different parts of Prisma to make it easier for newcomers to understand what each of our tools does.

Removing prisma2 dev

The prisma2 dev command has been removed from the Prisma 2 CLI. If you want to automatically re-generate Prisma Client upon a schema change, you can now add the --watch flag on the generate command:

prisma2 generate --watch

The prisma2 dev command was removed because it was using Prisma's migration functionality under the hood. Since migrations are considered experimental as of this release, we wanted to make sure that the main Prisma worfklows are not using them any more. Note that in the future we will provide an even better experience for developers who liked the quick turnaround time of prisma2 dev.

Removing the interactive prisma2 init wizard

The prisma2 init command has been simplified. It now only outputs a basic schema.prisma file with some helpful comments that explain potential next steps. A typical "getting started" flow now looks as follows:

  1. Run prisma2 init to create an empty Prisma schema file.
  2. Set your DB connection string as the url of the datasource block inside the Prisma schema.
  3. Run prisma2 introspect to test the connection and obtain your data model.
  4. Run prisma2 generate to generate Prisma Client.

You can then start using Prisma Client in your application:

import { PrismaClient } from 'prisma-client-js'
// or const { PrismaClient } = require('prisma-client-js')

const prisma = new PrismaClient()

Learn more in the updated "Getting Started"-guide.

If you want to get started with a new project instead of using an existing database, check out the available examples.

The interactive prisma2 init wizard was a very ambitious command to support developers in setting up their Prisma-based projects. While it helped some developers get started with an initial setup, it also showed to be very complex, confusing and difficult to maintain.

We therefore decided to remove the wizard and opted for a simpler version of prisma2 init that just sets up an initial Prisma schema file for you.

Introducing a new telemetry endpoint

To improve the Prisma tools, we've created a new telemetry endpoint. This endpoint is pinged by the prisma2 CLI upon the invokation of any command. Note that after the endpoint got pinged once, the pinging is paused for 48 hours before the next ping is sent from a command invokation. Learn more about the new telemetry server and the data it's sending in the docs.

You can opt-out of this behavior by setting the CHECKPOINT_DISABLE environment variable to 1, e.g.:

export CHECKPOINT_DISABLE=1

onDelete has been removed from the @relation attribute

While not causing an error, the onDelete argument on the @relation attribute didn't have any effect (i.e., it hadn't been implemented yet). To make the API surface simpler, we removed it from the Prisma schema for now.

Other changes

Renaming Prisma Framework to Prisma 2

We also decided to rename the Prisma Framework to Prisma 2 (or just "Prisma") again. The main reason for this is that many developers got confused about the term "framework" and misinterpreted it as a "web application framework" when it was supposed to refer to a "database framework". To prevent this confusion in the future, we decided to remove the "Framework"-part from its name.

As of now, we're still mainly referring to it as Prisma 2. After the initial launch in February, Prisma 2 will be referred to as just "Prisma".

Fixes and improvements per Prisma Framework repository

prisma2

prisma-client-js

migrate

prisma-engine

prisma - 2.0.0-preview019

Published by nikolasburk almost 5 years ago

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. using TRUNCATE _Migration;

Fixes and improvements per Prisma Framework repository

prisma2

photonjs

lift

prisma-engine

prisma - 2.0.0-preview018.1

Published by timsuchanek almost 5 years ago

prisma - 2.0.0-preview018

Published by nikolasburk almost 5 years ago

Today, we are issuing the eighteenth Preview release: 2.0.0-preview018 (short: preview018).

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

We removed the prisma2 convert command from the Prisma Framework CLI. If you're upgrading from Prisma 1 to the Prisma Framework, you can use introspection to generate your initial Prisma schema.

Fixes and improvements per Prisma Framework repository

prisma2

photonjs

lift

prisma-engine

prisma - 2.0.0-preview017.1

Published by timsuchanek almost 5 years ago

Fixes

As the last preview release Preview 17 introduced a lot of change with a lot of potential side effects, also a few small bugs got introduced.

These bugs are fixed by this patch.

The issues that got tackled by this patch:

prisma - 2.0.0-preview017

Published by nikolasburk almost 5 years ago

Today, we are issuing the seventeenth Preview release: 2.0.0-preview017 (short: preview017). Note that this release includes a major breaking change with respect to where Photon.js is being generated and how it's imported into your code. Read more below!

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

Photon.js generation and usage

With this release, we're implementing the facade package @prisma/photon for Photon.js. This means, instead of generating Photon.js into node_modules/@generated/photon, it is now being generated into node_modules/@prisma/photon.

Furthermore, you now must add the @prisma/photon package to your project dependencies:

npm install @prisma/photon

Consequently, the Photon constructor is now imported from @prisma/photon into your code:

- import { Photon } from '@generated/photon'
+ import { Photon } from '@prisma/photon'

Also note that the versions of @prisma/photon and your prisma2 CLI installation must be the same! It is therefore recommended to add prisma2 as a development dependency to you project. Global installations of prisma2 are discouraged because it's more difficult to keep them in sync with individual projects.

You can add prisma2 as a development dependeency as follows:

npm install prisma2 --save-dev

You can now invoke this local prisma2 installation using npx:

npx prisma2

Usage of custom binaries in Photon.js

If you're using the platforms field on your Photon.js generator to explicitly specify a build target for the binaries that are used by Photon.js, you might need to update the naming of the binaries. Here's how the names have changed:

Before After
windows windows
darwin darwin
linux-glibc-libssl1.0.1 debian-openssl-1.0.x
linux-glibc-libssl1.0.2 debian-openssl-1.0.x
linux-glibc-libssl1.1.0 debian-openssl-1.1.x
linux-glibc-libssl1.1.1 debian-openssl-1.1.x

If you're using a RHEL-based systems (Fedora, Centos, etc.), replace debian with rhel, e.g. rhel-openssl-1.1.x.

You can learn more about this in the spec.

Fixes and improvements per Prisma Framework repository

prisma2

photonjs

lift

prisma-engine

prisma - 2.0.0-preview016.2

Published by timsuchanek almost 5 years ago

prisma - 2.0.0-preview016.1

Published by timsuchanek almost 5 years ago

prisma - 2.0.0-preview016

Published by nikolasburk almost 5 years ago

Today, we are issuing the sixteenth Preview release: 2.0.0-preview016 (short: preview016).

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

Also a huge shoutout to @williamluke4 for his work on this PR: fix(Engine Commands) Pass JSON File to Query Engine 🙌

Major changes

This release contains major improvements to Photon's query engine. The biggest improvement here is that we're lifting the limitation that the query engine is only able to process one request at a time. In practice, this means that the query engine request throughput vastly increases. We see this as a major step towards making Photon.js production-ready! 🎉

Breaking changes

Due to a major refactoring in Lift's migration engine, your migrations are likely going to break if you upgrade to preview016 with an error similar to this: Error parsing the migration steps: Error("unknown field 'name', expected 'model'", line: 1, column: 59).

To get rid of this error, you'll need to manually delete the generated migrations folder from your file system and drop the _Migration table in your database.

Fixes and improvements per Prisma Framework repository

prisma2

photonjs

prisma-engine

prisma - 2.0.0-preview015

Published by timsuchanek almost 5 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)

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

prisma - 2.0.0-preview014.1

Published by timsuchanek about 5 years ago

Fixes

This patch release fixes a bug when using the native binaryTarget https://github.com/prisma/prisma2/issues/750

prisma - 2.0.0-preview014

Published by nikolasburk about 5 years ago

Today, we are issuing the fourteenth Preview release: 2.0.0-preview014 (short: preview014).

Note that we adjusted the versioning schema (from 2.0.0-preview-14 to 2.0.0-preview014) in order to fully comply to the semver spec.

Breaking changes

Removing the nexus-prisma generator from the Prisma schema

In version 2.0.0-preview014, the nexus-prisma generator is not available any more. When using nexus-prisma, you can install it as an npm dependency, just like you do with other libraries. Find an updated example of how to using nexus-prisma to build a GraphQL API here.

Self-relations must be disambiguated with the @relation attribute

In previous releases, this used to be a valid schema:

model User {
  id         String @id @default(cuid())
  marriedTo  User?
  spouseOf   User?
}

In previous versions, it was inferred that both relation fields, marriedTo and spouseOf, would belong to the same relation, i.e. it was interpreted as follows:

model User {
  id         String @id @default(cuid())
  marriedTo  User? @relation("MarriedUsers")
  spouseOf   User? @relation("MarriedUsers")
}

From this release onwards, adding the @relation attribute is required in order to disambiguate this relation.

The platforms field of generators in the schema has been renamed to binaryTargets

generator photon {
  provider = "photonjs"
  platforms = ["darwin"]
}

now becomes

generator photon {
  provider = "photonjs"
  binaryTargets = ["darwin"]
}

pinnedPlatform is now an env var

If you want to specify the concrete binary target or a binary path for the query engine, you can use the PRISMA_QUERY_ENGINE_BINARY env var. Just pass it in to the process running Photon.js and it will be picked up.

In order to also customize the Lift engine path, you can run the prisma2 cli while providing PRISMA_MIGRATION_ENGINE_BINARY.

Major changes

For this release, we have invested a lot into fixing bugs across the stack. Try it out yourself:

npm install -g prisma2
prisma2 init hello-world

Please share your feedback and report any issues you might encounter!

Fixes and improvements per Prisma 2 repository

prisma2

photonjs

lift

studio

prisma-engine

prisma - 2.0.0-preview013.3

Published by timsuchanek about 5 years ago

Fixes

Change in versioning scheme

We changed the versioning scheme from 2.0.0-preview-xx.y to 2.0.0-previewxx.y, as otherwise commands like yarn upgrade don't recognize the new versions, as semver couldn't parse our old version scheme.

Package Rankings
Top 0.41% on Npmjs.org
Top 17.22% on Repo1.maven.org
Top 3.78% on Proxy.golang.org
Badges
Extracted from project README
Prisma Tests Status Ecosystem Tests Status