Skip to content

try to find references to ORM v4 and lower #6761

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 6 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions content/200-orm/050-overview/500-databases/300-postgresql.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -161,10 +161,10 @@ The following arguments can be used:
| `host` | No | | Points to a directory that contains a socket to be used for the connection |
| `socket_timeout` | No | | Maximum number of seconds to wait until a single query terminates |
| `pgbouncer` | No | `false` | Configure the Engine to [enable PgBouncer compatibility mode](/orm/prisma-client/setup-and-configuration/databases-connections/pgbouncer) |
| `statement_cache_size` | No | `100` | Since 2.1.0: Specifies the number of [prepared statements](#prepared-statement-caching) cached per connection |
| `application_name` | No | | Since 3.3.0: Specifies a value for the application_name configuration parameter |
| `channel_binding` | No | `prefer` | Since 4.8.0: Specifies a value for the channel_binding configuration parameter |
| `options` | No | | Since 3.8.0: Specifies command line options to send to the server at connection start |
| `statement_cache_size` | No | `100` | Specifies the number of [prepared statements](#prepared-statement-caching) cached per connection |
| `application_name` | No | | Specifies a value for the application_name configuration parameter |
| `channel_binding` | No | `prefer` | Specifies a value for the channel_binding configuration parameter |
| `options` | No | | Specifies command line options to send to the server at connection start |

As an example, if you want to connect to a schema called `myschema`, set the connection pool size to `5` and configure a timeout for queries of `3` seconds. You can use the following arguments:

Expand Down
2 changes: 1 addition & 1 deletion content/200-orm/050-overview/500-databases/500-sqlite.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ When using `enum` fields in SQLite, be aware of the following:

SQLite is a loosely-typed database. If your Schema has a field of type `Int`, then Prisma ORM prevents you from inserting a value larger than an integer. However, nothing prevents the database from directly accepting a bigger number. These manually-inserted big numbers cause rounding errors when queried.

To avoid this problem, Prisma ORM 4.0.0 and later checks numbers on the way out of the database to verify that they fit within the boundaries of an integer. If a number does not fit, then Prisma ORM throws a P2023 error, such as:
To avoid this problem, Prisma ORM checks numbers on the way out of the database to verify that they fit within the boundaries of an integer. If a number does not fit, then Prisma ORM throws a P2023 error, such as:

```
Inconsistent column data: Conversion failed:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ sqlserver://HOST[:PORT];database=DATABASE;user={MyServer/MyUser};password={ThisI
| `socketTimeout` | No | | Number of seconds to wait for each query to succeed. |
| `isolationLevel` | No | | Sets [transaction isolation level](https://learn.microsoft.com/en-us/sql/t-sql/statements/set-transaction-isolation-level-transact-sql?view=sql-server-ver15). |
| `poolTimeout` | No | `10` | Maximum number of seconds to wait for a new connection from the pool. If all connections are in use, the database will return a `PoolTimeout` error after waiting for the given time. |
| <ul><li>`ApplicationName`</li><li>`Application Name`</li></ul>(case insensitive) | No | | Sets the application name for the connection. Since version 2.28.0. |
| <ul><li>`ApplicationName`</li><li>`Application Name`</li></ul>(case insensitive) | No | | Sets the application name for the connection. |
| `trustServerCertificate` | No | `false` | Configures whether to trust the server certificate. |
| `trustServerCertificateCA` | No | | A path to a certificate authority file to be used instead of the system certificates to authorize the server certificate. Must be either in `pem`, `crt` or `der` format. Cannot be used together with `trustServerCertificate` parameter. |

Expand Down Expand Up @@ -108,7 +108,7 @@ See [Supported databases](/orm/reference/supported-databases).

### Prisma Migrate caveats

Prisma Migrate is supported in [2.13.0](https://github.com/prisma/prisma/releases/tag/2.13.0) and later with the following caveats:
Prisma Migrate is supported with the following caveats:

#### Database schema names

Expand Down
12 changes: 1 addition & 11 deletions content/200-orm/050-overview/500-databases/840-cockroachdb.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -6,18 +6,8 @@ tocDepth: 3
toc: true
---

<TopBlock>

This guide discusses the concepts behind using Prisma ORM and CockroachDB, explains the commonalities and differences between CockroachDB and other database providers, and leads you through the process for configuring your application to integrate with CockroachDB.

</TopBlock>

<Admonition type="info">

The CockroachDB connector is generally available in versions `3.14.0` and later. It was first added as a [Preview feature](/orm/reference/preview-features) in version [`3.9.0`](https://github.com/prisma/prisma/releases/tag/3.9.0) with support for Introspection, and Prisma Migrate support was added in [`3.11.0`](https://github.com/prisma/prisma/releases/tag/3.11.0).

</Admonition>

## What is CockroachDB?

CockroachDB is a distributed database that is designed for scalability and high availability. Features include:
Expand Down Expand Up @@ -110,7 +100,7 @@ The fields passed to the `datasource` block are:

<Admonition type="info">

While `cockroachdb` and `postgresql` connectors are similar, it is mandatory to use the `cockroachdb` connector instead of `postgresql` when connecting to a CockroachDB database from version 5.0.0.
While `cockroachdb` and `postgresql` connectors are similar, it is mandatory to use the `cockroachdb` connector instead of `postgresql` when connecting to a CockroachDB database.

</Admonition>

Expand Down
14 changes: 3 additions & 11 deletions content/200-orm/050-overview/500-databases/850-planetscale.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -65,9 +65,7 @@ If you try to push to a production branch, you will get the [error message](/orm

#### 1. Set `relationMode = "prisma"`

PlanetScale does not use foreign key constraints in its database schema by default. However, Prisma ORM relies on foreign key constraints in the underlying database to enforce referential integrity between models in your Prisma schema.

In Prisma ORM versions 3.1.1 and later, you can [emulate relations in Prisma Client with the `prisma` relation mode](/orm/prisma-schema/data-model/relations/relation-mode#emulate-relations-in-prisma-orm-with-the-prisma-relation-mode), which avoids the need for foreign key constraints in the database.
PlanetScale does not use foreign key constraints in its database schema by default. However, Prisma ORM relies on foreign key constraints in the underlying database to enforce referential integrity between models in your Prisma schema. You can [emulate relations in Prisma Client with the `prisma` relation mode](/orm/prisma-schema/data-model/relations/relation-mode#emulate-relations-in-prisma-orm-with-the-prisma-relation-mode), which avoids the need for foreign key constraints in the database.

To enable emulation of relations in Prisma Client, set the `relationMode` field to `"prisma"` in the `datasource` block:

Expand All @@ -79,13 +77,7 @@ datasource db {
}
```

<Admonition type="info">

The ability to set the relation mode was introduced as part of the `referentialIntegrity` preview feature in Prisma ORM version 3.1.1, and is generally available in Prisma ORM versions 4.8.0 and later.<br /><br />The `relationMode` field was renamed in Prisma ORM version 4.5.0, and was previously named `referentialIntegrity`.

</Admonition>

If you use relations in your Prisma schema with the default `"foreignKeys"` option for the `relationMode` field, PlanetScale will error and Prisma ORM output the [P3021 error message](/orm/reference/error-reference#p3021) when it tries to create foreign keys. (In versions before 2.27.0 it will output a raw database error.)
If you use relations in your Prisma schema with the default `"foreignKeys"` option for the `relationMode` field, PlanetScale will error and Prisma ORM output the [P3021 error message](/orm/reference/error-reference#p3021) when it tries to create foreign keys.

#### 2. Create indexes on foreign keys

Expand Down Expand Up @@ -134,7 +126,7 @@ model Comment {

You can then add this change to your schema [using `db push`](#how-to-make-schema-changes-with-db-push).

In versions 4.7.0 and later, Prisma ORM warns you if you have a relation with no index on the relation scalar field. For more information, see [Index validation](/orm/prisma-schema/data-model/relations/relation-mode#index-validation).
Prisma ORM will warn you if you have a relation with no index on the relation scalar field. For more information, see [Index validation](/orm/prisma-schema/data-model/relations/relation-mode#index-validation).

<Admonition type="warning">

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@ metaTitle: 'Data sources (Reference)'
metaDescription: 'Data sources enable Prisma to connect to your database. This page explains how to configure data sources in your Prisma schema.'
---

<TopBlock>

A data source determines how Prisma ORM connects your database, and is represented by the [`datasource`](/orm/reference/prisma-schema-reference#datasource) block in the Prisma schema. The following data source uses the `postgresql` provider and includes a connection URL:

```prisma
Expand All @@ -20,10 +18,6 @@ A Prisma schema can only have _one_ data source. However, you can:
- [Programmatically override a data source `url` when creating your `PrismaClient`](/orm/reference/prisma-client-reference#programmatically-override-a-datasource-url)
- [Specify a different URL for Prisma Migrate's shadow database if you are working with cloud-hosted development databases](/orm/prisma-migrate/understanding-prisma-migrate/shadow-database#cloud-hosted-shadow-databases-must-be-created-manually)

> **Note**: Multiple provider support was removed in 2.22.0. Please see [Deprecation of provider array notation](https://github.com/prisma/prisma/issues/3834) for more information.

</TopBlock>

## Securing database connections

Some data source `provider`s allow you to configure your connection with SSL/TLS, and provide parameters for the `url` to specify the location of certificates.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ The Prisma CLI looks for the Prisma Schema in the following locations, in the fo
prisma generate --schema=./alternative/schema.prisma
```

2. The location specified in the `package.json` file (version 2.7.0 and later):
2. The location specified in the `package.json` file:

```json
"prisma": {
Expand Down
14 changes: 4 additions & 10 deletions content/200-orm/100-prisma-schema/20-data-model/10-models.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -439,7 +439,7 @@ Refer to the [relations documentation](/orm/prisma-schema/data-model/relations)

### Native types mapping

Version [2.17.0](https://github.com/prisma/prisma/releases/tag/2.17.0) and later support **native database type attributes** (type attributes) that describe the underlying database type:
Prisma ORM supports **native database type attributes** (type attributes) that describe the underlying database type:

```prisma highlight=3;normal
model Post {
Expand Down Expand Up @@ -795,7 +795,7 @@ model Post {
Default values can be:

- Static values that correspond to the field type, such as `5` (`Int`), `Hello` (`String`), or `false` (`Boolean`)
- [Lists](/orm/reference/prisma-schema-reference#-modifier) of static values, such as `[5, 6, 8]` (`Int[]`) or `["Hello", "Goodbye"]` (`String`[]). These are available in Prisma ORM versions `4.0.0` and later, when using supported databases (PostgreSQL, CockroachDB and MongoDB)
- [Lists](/orm/reference/prisma-schema-reference#-modifier) of static values, such as `[5, 6, 8]` (`Int[]`) or `["Hello", "Goodbye"]` (`String`[]). These are available when using supported databases (PostgreSQL, CockroachDB and MongoDB)
- [Functions](#using-functions), such as [`now()`](/orm/reference/prisma-schema-reference#now) or [`uuid()`](/orm/reference/prisma-schema-reference#uuid)
- JSON data. Note that JSON needs to be enclosed with double-quotes inside the `@default` attribute, e.g.: `@default("[]")`. If you want to provide a JSON object, you need to enclose it with double-quotes and then escape any internal double quotes using a backslash, e.g.: `@default("{ \"hello\": \"world\" }")`.

Expand Down Expand Up @@ -913,7 +913,7 @@ Refer to the documentation on [working with composite unique identifiers](/orm/p

#### Composite type unique constraints

When using the MongoDB provider in version `3.12.0` and later, you can define a unique constraint on a field of a [composite type](#defining-composite-types) using the syntax `@@unique([compositeType.field])`. As with other fields, composite type fields can be used as part of a multi-column unique constraint.
When using the MongoDB provider you can define a unique constraint on a field of a [composite type](#defining-composite-types) using the syntax `@@unique([compositeType.field])`. As with other fields, composite type fields can be used as part of a multi-column unique constraint.

The following example defines a multi-column unique constraint based on the `email` field of the `User` model and the `number` field of the `Address` composite type which is used in `User.address`:

Expand Down Expand Up @@ -975,7 +975,7 @@ You can optionally define a [custom index name](/orm/prisma-schema/data-model/da

#### Defining composite type indexes

When using the MongoDB provider in version `3.12.0` and later, you can define an index on a field of a [composite type](#defining-composite-types) using the syntax `@@index([compositeType.field])`. As with other fields, composite type fields can be used as part of a multi-column index.
When using the MongoDB provider you can define an index on a field of a [composite type](#defining-composite-types) using the syntax `@@index([compositeType.field])`. As with other fields, composite type fields can be used as part of a multi-column index.

The following example defines a multi-column index based on the `email` field of the `User` model and the `number` field of the `Address` composite type:

Expand Down Expand Up @@ -1067,12 +1067,6 @@ enum Role {

## Defining composite types

<Admonition type="info">

Composite types were added in version `3.10.0` under the `mongodb` Preview feature flag and are in General Availability since version `3.12.0`.

</Admonition>

<Admonition type="warning">

Composite types are currently only available on MongoDB.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ model Profile {

<Admonition type="warning">

In MySQL, you can create a foreign key with only an index on the referenced side, and not a unique constraint. In Prisma ORM versions 4.0.0 and later, if you introspect a relation of this type it will trigger a validation error. To fix this, you will need to add a `@unique` constraint to the referenced field.
In MySQL, you can create a foreign key with only an index on the referenced side, and not a unique constraint. If you introspect a relation of this type it will trigger a validation error. To fix this, you will need to add a `@unique` constraint to the referenced field.

</Admonition>

Expand Down Expand Up @@ -190,8 +190,6 @@ model User {
}
```

This restriction was introduced in 2.12.0.

However, you can choose if the side of the relation _with_ a relation scalar should be optional or mandatory.

### Mandatory 1-1 relation
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ model Post {

<Admonition type="warning">

In MySQL, you can create a foreign key with only an index on the referenced side, and not a unique constraint. In Prisma ORM versions 4.0.0 and later, if you introspect a relation of this type it will trigger a validation error. To fix this, you will need to add a `@unique` constraint to the referenced field.
In MySQL, you can create a foreign key with only an index on the referenced side, and not a unique constraint. If you introspect a relation of this type it will trigger a validation error. To fix this, you will need to add a `@unique` constraint to the referenced field.

</Admonition>

Expand Down
Loading
Loading