Skip to content

Commit

Permalink
Update documentation for ORM 6.2
Browse files Browse the repository at this point in the history
Fixes #6565

---

For more details, open the [Copilot Workspace session](https://copilot-workspace.githubnext.com/prisma/docs/issues/6565?shareId=XXXX-XXXX-XXXX-XXXX).
  • Loading branch information
jharrell committed Jan 3, 2025
1 parent 38b134e commit 1f77dd2
Show file tree
Hide file tree
Showing 4 changed files with 60 additions and 65 deletions.
5 changes: 4 additions & 1 deletion content/200-orm/050-overview/500-databases/500-sqlite.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,12 @@ The SQLite connector maps the [scalar types](/orm/prisma-schema/data-model/model
| `Float` | `REAL` |
| `Decimal` | `DECIMAL` |
| `DateTime` | `NUMERIC` |
| `Json` | Not supported |
| `Json` | \* |
| `Enum` | \* |
| `Bytes` | `BLOB` |

> \* As SQLite does not have native `JSON` or `ENUM` types, these are implemented via shims and consistency is maintained by Prisma ORM.
## Rounding errors on big numbers

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.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@ metaDescription: 'How to read, write, and filter by Json fields.'
tocDepth: 3
---

<TopBlock>

Use the [`Json`](/orm/reference/prisma-schema-reference#json) Prisma ORM field type to read, write, and perform basic filtering on JSON types in the underlying database. In the following example, the `User` model has an optional `Json` field named `extendedPetsData`:

```prisma highlight=6;normal
Expand Down Expand Up @@ -35,7 +33,6 @@ Example field value:
}
```

> **Note**: The `Json` field is only supported if the [underlying database](/orm/overview) has a corresponding JSON data type.

The `Json` field supports a few additional types, such as `string` and `boolean`. These additional types exist to match the types supported by [`JSON.parse()`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/JSON/parse):

Expand All @@ -49,8 +46,6 @@ export declare type JsonValue =
| JsonArray
```
</TopBlock>
## Use cases for JSON fields
Reasons to store data as JSON rather than representing data as related models include:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3357,7 +3357,7 @@ Defines an [enum](/orm/prisma-schema/data-model/models#defining-enums) .
### Remarks

- Enums are natively supported by [PostgreSQL](https://www.postgresql.org/docs/current/datatype-enum.html) and [MySQL](https://dev.mysql.com/doc/refman/8.0/en/enum.html)
- Enums are implemented and enforced at Prisma ORM level in MongoDB
- Enums are implemented and enforced at Prisma ORM level in SQLite and MongoDB

### Naming conventions

Expand Down
113 changes: 55 additions & 58 deletions content/200-orm/500-reference/350-database-features.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -3,90 +3,87 @@ title: 'Database features matrix'
metaTitle: 'Database features matrix'
metaDescription: 'Learn which database features are supported in Prisma ORM and how they map to the different Prisma ORM tools.'
wide: true
tocDepth: 3
---

<TopBlock>

This page gives an overview of the features which are provided by the databases that Prisma ORM supports. Additionally, it explains how each of these features can be used in Prisma ORM with pointers to further documentation.

> **Note**: If a feature is not supported natively by the database, it's also not available in Prisma ORM.
</TopBlock>

## Relational database features

This section describes which database features exist on the relational databases that are currently supported by Prisma ORM. The **Prisma schema** column indicates how a certain feature can be represented in the [Prisma schema](/orm/prisma-schema) and links to its documentation. Note that database features can be used in **Prisma Client** even though they might not yet be representable in the Prisma schema.

:::note

These features are _only_ for relational databases. Supported features for NoSQL databases, like MongoDB, can [be found below](#nosql-database-features).

:::

### Constraints

| Constraint | PostgreSQL | Microsoft SQL Server | MySQL | SQLite | CockroachDB | Prisma schema | Prisma Client | Prisma Migrate |
| ------------- | :--------: | :------------------: | :---: | :----: | :---------: | :--------------------------------------------------------------------------------------: | :-----------: | :------------: |
| `PRIMARY KEY` | ✔️ | ✔️ | ✔️ | ✔️ | ✔️ | [`@id` and `@@id`](/orm/prisma-schema/data-model/models#defining-an-id-field) | ✔️ | ✔️ |
| `FOREIGN KEY` | ✔️ | ✔️ | ✔️ | ✔️ | ✔️ | [Relation fields](/orm/prisma-schema/data-model/relations#relation-fields) | ✔️ | ✔️ |
| `UNIQUE` | ✔️ | ✔️† | ✔️ | ✔️ | ✔️ | [`@unique` and `@@unique`](/orm/prisma-schema/data-model/models#defining-a-unique-field) | ✔️ | ✔️ |
| `CHECK` | ✔️ | ✔️ | ✔️\* | ✔️ | ✔️ | Not yet | ✔️ | Not yet |
| `NOT NULL` | ✔️ | ✔️ | ✔️ | ✔️ | ✔️ | [`?`](/orm/prisma-schema/data-model/models#type-modifiers) | ✔️ | ✔️ |
| `DEFAULT` | ✔️ | ✔️ | ✔️ | ✔️ | ✔️ | [`@default`](/orm/prisma-schema/data-model/models#defining-a-default-value) | ✔️ | ✔️ |
| Constraint | Supported | Prisma schema | Prisma Client | Prisma Migrate |
| ------------- | :-------: | :--------------------------------------------------------------------------------------: | :-----------: | :------------: |
| `PRIMARY KEY` | ✔️ | [`@id` and `@@id`](/orm/prisma-schema/data-model/models#defining-an-id-field) | ✔️ | ✔️ |
| `FOREIGN KEY` | ✔️ | [Relation fields](/orm/prisma-schema/data-model/relations#relation-fields) | ✔️ | ✔️ |
| `UNIQUE` | ✔️\* | [`@unique` and `@@unique`](/orm/prisma-schema/data-model/models#defining-a-unique-field) | ✔️ | ✔️ |
| `CHECK` | ✔️ | Not yet | ✔️ | Not yet |
| `NOT NULL` | ✔️ | [`?`](/orm/prisma-schema/data-model/models#type-modifiers) | ✔️ | ✔️ |
| `DEFAULT` | ✔️ | [`@default`](/orm/prisma-schema/data-model/models#defining-a-default-value) | ✔️ | ✔️ |

- \*In [MySQL 8 and higher](https://dev.mysql.com/doc/refman/8.0/en/create-table-check-constraints.html)
-[Caveats apply when using the `UNIQUE` constraint with Microsoft SQL Server](/orm/overview/databases/sql-server#data-model-limitations)
> \* [Caveats apply when using the `UNIQUE` constraint with Microsoft SQL Server](/orm/overview/databases/sql-server#data-model-limitations)
> Only supported in MySQL in [version 8 and higher](https://dev.mysql.com/doc/refman/8.0/en/create-table-check-constraints.html).
### Referential Actions (Delete and Update behaviors for foreign key references)

| Deletion behavior | PostgreSQL | Microsoft SQL Server | MySQL | SQLite | CockroachDB | Prisma schema | Prisma Client | Prisma Migrate |
| ----------------- | :--------: | :------------------: | :---: | :----: | :---------: | :-----------: | :-----------: | :------------: |
| `CASCADE` | ✔️ | ✔️ | ✔️ | ✔️ | ✔️ | **✔️** | ✔️ | **✔️** |
| `RESTRICT` | ✔️ | No | ✔️ | ✔️ | ✔️ | **✔️**| ✔️ | **✔️** |
| `NO ACTION` | ✔️ | ✔️ | ✔️ | ✔️ | ✔️ | **✔️** | ✔️ | **✔️** |
| `SET DEFAULT` | ✔️ | ✔️ | ✔️ | ✔️ | ✔️ | **✔️** | ✔️ | **✔️** |
| `SET NULL` | ✔️ | ✔️ | ✔️ | ✔️ | ✔️ | **✔️** | ✔️ | **✔️** |
| Deletion behavior | Supported | Prisma schema | Prisma Client | Prisma Migrate |
| ----------------- | :-------: | :-----------: | :-----------: | :------------: |
| `CASCADE` | ✔️ | ✔️ | ✔️ | ✔️ |
| `RESTRICT` | ✔️\* | ✔️ | ✔️ | ✔️ |
| `NO ACTION` | ✔️ | ✔️ | ✔️ | ✔️ |
| `SET DEFAULT` | ✔️ | ✔️ | ✔️ | ✔️ |
| `SET NULL` | ✔️ | ✔️ | ✔️ | ✔️ |

- † In [2.26.0](https://github.com/prisma/prisma/releases/tag/2.26.0) and later you can define [referential actions](/orm/prisma-schema/data-model/relations/referential-actions) on your relation fields. Referential actions determine what should happen to a record when a related record is deleted or updated.
> \* `RESTRICT` is not supported in Microsoft SQL Server.
### Indexes

| Index | PostgreSQL | Microsoft SQL Server | MySQL | SQLite | CockroachDB | Prisma schema | Prisma Client | Prisma Migrate |
| -------------- | :--------: | :------------------: | :---: | :----: | :---------: | :---------------------------------------------------------------------------------------------------------------------: | :-----------: | :------------: |
| `UNIQUE` | ✔️ | ✔️ | ✔️ | ✔️ | ✔️ | [`@unique` and `@@unique`](/orm/prisma-schema/data-model/models#defining-a-unique-field) | ✔️ | ✔️ |
| `USING` | ✔️ | No | No | No | ✔️ | [`type`](/orm/prisma-schema/data-model/indexes#configuring-the-access-type-of-indexes-with-type-postgresql)<sup>†</sup> | ✔️ | ✔️<sup>†</sup> |
| `WHERE` | ✔️ | ✔️ | ✔️ | ✔️ | ✔️ | Not yet | ✔️ | Not yet |
| `(expression)` | ✔️ | ✔️ | ✔️ | ✔️ | ✔️ | Not yet | ✔️ | Not yet |
| `INCLUDE` | ✔️ | ✔️ | No | No | ✔️ | Not yet | ✔️ | Not yet |

- † Available in preview in 3.6.0 and later and in general availability in 4.0.0 and later, with the PostgreSQL connector only.
| Index | Supported | Prisma schema | Prisma Client | Prisma Migrate |
| -------------- | :-------------: | :---------------------------------------------------------------------------------------------------------: | :-----------: | :------------: |
| `UNIQUE` | ✔️ | [`@unique` and `@@unique`](/orm/prisma-schema/data-model/models#defining-a-unique-field) | ✔️ | ✔️ |
| `USING` | PostgreSQL only | [`type`](/orm/prisma-schema/data-model/indexes#configuring-the-access-type-of-indexes-with-type-postgresql) | ✔️ | ✔️ |
| `WHERE` | ✔️ | Not yet | ✔️ | Not yet |
| `(expression)` | ✔️ | Not yet | ✔️ | Not yet |
| `INCLUDE` | PostgreSQL and Microsoft SQL Server only | Not yet | ✔️ | Not yet |

Algorithm specified via `USING`:

| Index type (Algorithm) | PostgreSQL | Microsoft SQL Server | MySQL | SQLite | CockroachDB | Prisma schema | Prisma Client | Prisma Migrate |
| ---------------------- | :--------: | :------------------: | :---: | :----: | :---------: | :-----------: | :-----------: | :------------: |
| B-tree | ✔️ | ✔️ | ✔️ | ✔️ | ✔️ | ✔️| ✔️ | Not yet |
| Hash | ✔️ | ✔️ | ✔️ | ✔️ | ✔️ | ✔️| ✔️ | Not yet |
| GiST | ✔️ | ✔️ | No | No | ✔️ | ✔️| ✔️\* | Not yet |
| GIN | ✔️ | ✔️ | No | No | ✔️ | ✔️| ✔️\* | Not yet |
| BRIN | ✔️ | ✔️ | No | No | ✔️ | ✔️| ✔️\* | Not yet |
| SP-GiST | ✔️ | ✔️ | No | No | ✔️ | ✔️| ✔️\* | Not yet |
| Index type (Algorithm) | Supported | Prisma schema | Prisma Client | Prisma Migrate |
| ---------------------- | :-------: | :-----------: | :-----------: | :------------: |
| B-tree | ✔️ | ✔️| ✔️ | Not yet |
| Hash | ✔️ | ✔️| ✔️ | Not yet |
| GiST | ✔️\* | ✔️| ✔️\* | Not yet |
| GIN | ✔️\* | ✔️| ✔️\* | Not yet |
| BRIN | ✔️\* | ✔️| ✔️\* | Not yet |
| SP-GiST | ✔️\* | ✔️| ✔️\* | Not yet |

- \* Only available if natively supported by database.
- \* Not supported for MySQL and SQLite
- † Available with the PostgreSQL connector only in Prisma ORM versions `4.0.0` and later.

### Misc

| Feature | PostgreSQL | Microsoft SQL Server | MySQL | SQLite | CockroachDB | Prisma schema | Prisma Client | Prisma Migrate |
| --------------------------------- | :--------: | :------------------: | :---: | :----: | :---------: | :--------------------------------------------------------------------------------: | :-----------: | :------------: |
| Autoincrementing IDs | ✔️ | ✔️ | ✔️ | ✔️ | ✔️ | [`autoincrement()`](/orm/prisma-schema/data-model/models#defining-a-default-value) | ✔️ | ✔️ |
| Arrays | ✔️ | No | No | No | ✔️ | [`[]`](/orm/prisma-schema/data-model/models#type-modifiers) | ✔️\* | ✔️\* |
| Enums | ✔️ | No | ✔️ | No | ✔️ | [`enum`](/orm/prisma-schema/data-model/models#defining-enums) | ✔️\* | ✔️\* |
| Native database types | ✔️ | ✔️ | ✔️ | ✔️ | ✔️ | ✔️ | ✔️ | Not yet |
| SQL Views | ✔️ | ✔️ | ✔️ | ✔️ | ✔️ | Not yet | Not yet | Not yet |
| JSON support | ✔️ | **✔️** | ✔️ | No | ✔️‡ | ✔️\* | ✔️\* | ✔️\* |
| Fuzzy/Phrase full text search | ✔️ | ✔️ | ✔️ | No | ✔️ | Not yet | Not yet | Not yet |
| Table inheritance | ✔️ | ✔️ | No | No | ✔️ | Not yet | ✔️\* | Not yet |
| Authorization and user management | ✔️ | ✔️ | ✔️ | No | ✔️ | Not yet | Not yet | Not yet |

- \* Only available if natively supported by database.
-Only supports JSON through SQL functions, but doesn't have a JSON column type. Therefore client JSON operations are not supported.
-JSON arrays are not yet supported: see the [CockroachDB connector page](/orm/overview/databases/cockroachdb) for details
| Feature | Supported | Prisma schema | Prisma Client | Prisma Migrate |
| --------------------------------- | :-------: | :--------------------------------------------------------------------------------: | :-----------: | :------------: |
| Autoincrementing IDs | ✔️ | [`autoincrement()`](/orm/prisma-schema/data-model/models#defining-a-default-value) | ✔️ | ✔️ |
| Arrays | PostgreSQL only | [`[]`](/orm/prisma-schema/data-model/models#type-modifiers) | ✔️ | ✔️ |
| Enums | ✔️\* | [`enum`](/orm/prisma-schema/data-model/models#defining-enums) | ✔️ | ✔️ |
| Native database types | ✔️ | ✔️ | ✔️ | Not yet |
| SQL Views | ✔️ | Not yet | Not yet | Not yet |
| JSON support | ✔️† | ✔️ | ✔️ | ✔️ |
| Fuzzy/Phrase full text search | ✔️ | Not yet | Not yet | Not yet |
| Table inheritance | PostgreSQL and Microsoft SQL Server only | Not yet | ✔️ | Not yet |
| Authorization and user management | ✔️ | Not yet | Not yet | Not yet |

- \* Not supported by Microsoft SQL Server
- † JSON and Enum types are supported in SQLite as of Prisma ORM 6.2.0.
-Not supported by SQLite

## NoSQL database features

Expand Down

0 comments on commit 1f77dd2

Please sign in to comment.