Skip to content
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

docs for multi-file Prisma schema and clean up #6059

Merged
merged 18 commits into from
Jun 4, 2024
Merged
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
2 changes: 1 addition & 1 deletion content/100-getting-started/01-quickstart.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ Finally, set up Prisma ORM with the `init` command of the Prisma CLI:
npx prisma init --datasource-provider sqlite
```

This creates a new `prisma` directory with your Prisma schema file and configures SQLite as your database. You're now ready to model your data and create your database with some tables.
This creates a new `prisma` directory with a `prisma.schema` file and configures SQLite as your database. You're now ready to model your data and create your database with some tables.

## 2. Model your data in the Prisma schema

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ You can now invoke the Prisma CLI by prefixing it with `npx`:
npx prisma
```

Next, set up your Prisma ORM project by creating your [Prisma schema](/orm/prisma-schema) file with the following command:
Next, set up your Prisma ORM project by creating your [Prisma Schema](/orm/prisma-schema) file with the following command:

```terminal copy
npx prisma init
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,13 +51,13 @@ You can now invoke the Prisma CLI by prefixing it with `npx`:
npx prisma
```

Next, set up your Prisma ORM project by creating your [Prisma schema](/orm/prisma-schema) file with the following command:
Next, set up your Prisma ORM project by creating your [Prisma Schema](/orm/prisma-schema) file with the following command:

```terminal copy
npx prisma init
```

This command does two things:

- creates a new directory called `prisma` that contains a file called `schema.prisma`, which contains the Prisma schema with your database connection variable and schema models
- creates a new directory called `prisma` that contains a file called `schema.prisma`, which contains the Prisma Schema with your database connection variable and schema models
- creates the [`.env` file](/orm/more/development-environment/environment-variables/env-files) in the root directory of the project, which is used for defining environment variables (such as your database connection)
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ You can now invoke the Prisma CLI by prefixing it with `npx`:
npx prisma
```

Next, set up your Prisma ORM project by creating your [Prisma schema](/orm/prisma-schema) file with the following command:
Next, set up your Prisma ORM project by creating your [Prisma Schema](/orm/prisma-schema) file with the following command:

```terminal copy
npx prisma init
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ You can now invoke the Prisma CLI by prefixing it with `npx`:
npx prisma
```

Next, set up your Prisma ORM project by creating your [Prisma schema](/orm/prisma-schema) file with the following command:
Next, set up your Prisma ORM project by creating your [Prisma Schema](/orm/prisma-schema) file with the following command:

```terminal copy
npx prisma init
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ You can now invoke the Prisma CLI by prefixing it with `npx`:
npx prisma
```

Next, set up your Prisma ORM project by creating your [Prisma schema](/orm/prisma-schema) file with the following command:
Next, set up your Prisma ORM project by creating your [Prisma Schema](/orm/prisma-schema) file with the following command:

```terminal copy
npx prisma init
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ You can now invoke the Prisma CLI by prefixing it with `npx`:
npx prisma
```

Next, set up your Prisma ORM project by creating your [Prisma schema](/orm/prisma-schema) file with the following command:
Next, set up your Prisma ORM project by creating your [Prisma Schema](/orm/prisma-schema) file with the following command:

```terminal copy
npx prisma init
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ You can now invoke the Prisma CLI by prefixing it with `npx`:
npx prisma
```

Next, set up your Prisma ORM project by creating your [Prisma schema](/orm/prisma-schema) file with the following command:
Next, set up your Prisma ORM project by creating your [Prisma Schema](/orm/prisma-schema) file with the following command:

```terminal copy
npx prisma init
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ You can now invoke the Prisma CLI by prefixing it with `npx`:
npx prisma
```

Next, set up your Prisma ORM project by creating your [Prisma schema](/orm/prisma-schema) file with the following command:
Next, set up your Prisma ORM project by creating your [Prisma Schema](/orm/prisma-schema) file with the following command:

```terminal copy
npx prisma init
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ You can now invoke the Prisma CLI by prefixing it with `npx`:
npx prisma
```

Next, set up your Prisma ORM project by creating your [Prisma schema](/orm/prisma-schema) file with the following command:
Next, set up your Prisma ORM project by creating your [Prisma Schema](/orm/prisma-schema) file with the following command:

```terminal copy
npx prisma init
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ You can now invoke the Prisma CLI by prefixing it with `npx`:
npx prisma
```

Next, set up your Prisma ORM project by creating your [Prisma schema](/orm/prisma-schema) file with the following command:
Next, set up your Prisma ORM project by creating your [Prisma Schema](/orm/prisma-schema) file with the following command:

```terminal copy
npx prisma init
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ You can now invoke the Prisma CLI by prefixing it with `npx`:
npx prisma
```

Next, set up your Prisma ORM project by creating your [Prisma schema](/orm/prisma-schema) file with the following command:
Next, set up your Prisma ORM project by creating your [Prisma Schema](/orm/prisma-schema) file with the following command:

```terminal copy
npx prisma init
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ To get started with Prisma Client, you need to install the `@prisma/client` pack
npm install @prisma/client
```

The install command invokes `prisma generate` for you which reads your Prisma schema and generates a version of Prisma Client that is _tailored_ to your models.
The install command invokes `prisma generate` for you which reads your Prisma Schema and generates a version of Prisma Client that is _tailored_ to your models.

![Install and generate Prisma Client](/img/getting-started/prisma-client-install-and-generate.png)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ npx prisma db pull

This command reads the environment variable used to define the `url` in your `schema.prisma`, `DATABASE_URL`, that in our case is set in `.env` and connects to your database. Once the connection is established, it introspects the database (i.e. it _reads the database schema_). It then translates the database schema from SQL into a Prisma data model.

After the introspection is complete, your Prisma schema file was updated:
After the introspection is complete, your Prisma schema is updated:

![Introspect your database](/img/getting-started/prisma-db-pull-generate-schema.png)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ npx prisma db pull

This command reads the `DATABASE_URL` environment variable that's defined in `.env` and connects to your database. Once the connection is established, it introspects the database (i.e. it _reads the database schema_). It then translates the database schema from SQL into a Prisma data model.

After the introspection is complete, your Prisma schema file was updated:
After the introspection is complete, your Prisma schema is updated:

![Introspect your database](/img/getting-started/prisma-db-pull-generate-schema.png)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ npx prisma db pull

This command reads the `DATABASE_URL` environment variable that's defined in `.env` and connects to your database. Once the connection is established, it introspects the database (i.e. it _reads the database schema_). It then translates the database schema from SQL into a Prisma data model.

After the introspection is complete, your Prisma schema file was updated:
After the introspection is complete, your Prisma schema is updated:

![Introspect your database](/img/getting-started/prisma-db-pull-generate-schema.png)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ npx prisma db pull

This command reads the `DATABASE_URL` environment variable that's defined in `.env` and connects to your database. Once the connection is established, it introspects the database (i.e. it _reads the database schema_). It then translates the database schema from SQL into a data model in your Prisma schema.

After the introspection is complete, your Prisma schema file was updated:
After the introspection is complete, your Prisma schema is updated:

![Introspect your database with Prisma ORM](/img/getting-started/prisma-db-pull-generate-schema.png)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ npx prisma db pull

This command reads the `DATABASE_URL` environment variable that's defined in `.env` and connects to your database. Once the connection is established, it introspects the database (i.e. it _reads the database schema_). It then translates the database schema from SQL into a Prisma data model.

After the introspection is complete, your Prisma schema file was updated:
After the introspection is complete, your Prisma schema is updated:

![Introspect your database](/img/getting-started/prisma-db-pull-generate-schema.png)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ npx prisma db pull

This command reads the environment variable used to define the `url` in your `schema.prisma`, `DATABASE_URL`, that in our case is set in `.env` and connects to your database. Once the connection is established, it introspects the database (i.e. it _reads the database schema_). It then translates the database schema from SQL into a Prisma data model.

After the introspection is complete, your Prisma schema file was updated:
After the introspection is complete, your Prisma schema is updated:

![Introspect your database](/img/getting-started/prisma-db-pull-generate-schema.png)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ npx prisma db pull

This command reads the `DATABASE_URL` environment variable that's defined in `.env` and connects to your database. Once the connection is established, it introspects the database (i.e. it _reads the database schema_). It then translates the database schema from SQL into a Prisma data model.

After the introspection is complete, your Prisma schema file was updated:
After the introspection is complete, your Prisma schema is updated:

![Introspect your database](/img/getting-started/prisma-db-pull-generate-schema.png)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ npx prisma db pull

This command reads the `DATABASE_URL` environment variable that's defined in `.env` and connects to your database. Once the connection is established, it introspects the database (i.e. it _reads the database schema_). It then translates the database schema from SQL into a Prisma data model.

After the introspection is complete, your Prisma schema file was updated:
After the introspection is complete, your Prisma schema is updated:

![Introspect your database](/img/getting-started/prisma-db-pull-generate-schema.png)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ npx prisma db pull

This command reads the `DATABASE_URL` environment variable that's defined in `.env` and connects to your database. Once the connection is established, it introspects the database (i.e. it _reads the database schema_). It then translates the database schema from SQL into a data model in your Prisma schema.

After the introspection is complete, your Prisma schema file was updated:
After the introspection is complete, your Prisma schema is updated:

![Introspect your database with Prisma ORM](/img/getting-started/prisma-db-pull-generate-schema.png)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ npx prisma db pull

This command reads the `DATABASE_URL` environment variable that's defined in `.env` and connects to your database. Once the connection is established, it introspects the database (i.e. it _reads the database schema_). It then translates the database schema from SQL into a Prisma data model.

After the introspection is complete, your Prisma schema file was updated:
After the introspection is complete, your Prisma schema is updated:

![Introspect your database](/img/getting-started/prisma-db-pull-generate-schema.png)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ Prisma Client can be used in _any_ Node.js (supported versions) or TypeScript ba

### The Prisma schema

Every project that uses a tool from the Prisma ORM toolkit starts with a [Prisma schema file](/orm/prisma-schema). The Prisma schema allows developers to define their _application models_ in an intuitive data modeling language. It also contains the connection to a database and defines a _generator_:
Every project that uses a tool from the Prisma ORM toolkit starts with a [Prisma schema](/orm/prisma-schema). The Prisma schema allows developers to define their _application models_ in an intuitive data modeling language. It also contains the connection to a database and defines a _generator_:

<TabbedContent code>
<TabItem value="Relational databases">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ Prisma ORM is a **next-generation ORM** that makes working with databases easy f

> **Note:** Since Prisma Client is the most prominent tool, we often refer to it as simply Prisma.

The three tools use the [Prisma schema](/orm/prisma-schema) as a single source of truth for the database schema, your application's object schema, and the mapping between the two. It's defined by you and is your main configuration file for Prisma ORM.
These three tools use the [Prisma schema](/orm/prisma-schema) as a single source of truth for the database schema, your application's object schema, and the mapping between the two. It's defined by you and is your main way of configuring Prisma ORM.

Prisma ORM makes you productive and confident in the software you're building with features such as _type safety_, rich auto-completion, and a natural API for fetching relations.

Expand Down Expand Up @@ -440,7 +440,7 @@ In summary, Prisma ORM is a new kind of Data Mapper ORM that differs from tradit

Unlike traditional ORMs, with Prisma ORM, you define the Prisma schema – a declarative single source of truth for the database schema and application models. All queries in Prisma Client return plain JavaScript objects which makes the process of interacting with the database a lot more natural as well as more predictable.

Prisma ORM supports two main workflows for starting new projects and adopting in an existing project. For both workflows, the Prisma schema is the main configuration file.
Prisma ORM supports two main workflows for starting new projects and adopting in an existing project. For both workflows, your main avenue for configuration is via the Prisma schema.

Like all abstractions, both Prisma ORM and other ORMs hide away some of the underlying details of the database with different assumptions.

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ By default, the PostgreSQL connector contains a database driver responsible for

## Example

To connect to a PostgreSQL database server, you need to configure a [`datasource`](/orm/prisma-schema/overview/data-sources) block in your [Prisma schema file](/orm/prisma-schema):
To connect to a PostgreSQL database server, you need to configure a [`datasource`](/orm/prisma-schema/overview/data-sources) block in your [Prisma schema](/orm/prisma-schema):

```prisma file=schema.prisma showLineNumbers
datasource db {
Expand Down
2 changes: 1 addition & 1 deletion content/200-orm/050-overview/500-databases/400-mysql.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ By default, the MySQL connector contains a database driver responsible for conne

## Example

To connect to a MySQL database server, you need to configure a [`datasource`](/orm/prisma-schema/overview/data-sources) block in your [Prisma schema file](/orm/prisma-schema):
To connect to a MySQL database server, you need to configure a [`datasource`](/orm/prisma-schema/overview/data-sources) block in your [Prisma schema](/orm/prisma-schema):

```prisma file=schema.prisma showLineNumbers
datasource db {
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 @@ -15,7 +15,7 @@ By default, the SQLite connector contains a database driver responsible for conn

## Example

To connect to a SQLite database file, you need to configure a [`datasource`](/orm/prisma-schema/overview/data-sources) block in your [schema file](/orm/prisma-schema):
To connect to a SQLite database file, you need to configure a [`datasource`](/orm/prisma-schema/overview/data-sources) block in your [Prisma schema](/orm/prisma-schema):

```prisma file=schema.prisma showLineNumbers
datasource db {
Expand Down
8 changes: 4 additions & 4 deletions content/200-orm/050-overview/500-databases/600-mongodb.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ Some aspects of using Prisma ORM with MongoDB are the same as when using Prisma

## Differences to consider

MongoDB's document-based structure and flexible schemas means that using Prisma ORM with MongoDB differs from using it with a relational database in a number of ways. These are some areas where there are differences that you need to be aware of:
MongoDB's document-based structure and flexible schema means that using Prisma ORM with MongoDB differs from using it with a relational database in a number of ways. These are some areas where there are differences that you need to be aware of:

- **Defining IDs**: MongoDB documents have an `_id` field (that often contains an [ObjectID](https://www.mongodb.com/docs/manual/reference/bson-types/#std-label-objectid)). Prisma ORM does not support fields starting with `_`, so this needs to be mapped to a Prisma ORM field using the `@map` attribute. For more information, see [Defining IDs in MongoDB](/orm/prisma-schema/data-model/models#defining-ids-in-mongodb).

Expand All @@ -55,7 +55,7 @@ This section provides instructions for how to carry out tasks that require steps

### How to migrate existing data to match your Prisma schema

Migrating your database over time is an important part of the development cycle. During development, you will need to update your Prisma schema file (for example, to add new fields), then update the data in your development environment’s database, and eventually push both the updated schema and the new data to the production database.
Migrating your database over time is an important part of the development cycle. During development, you will need to update your Prisma schema (for example, to add new fields), then update the data in your development environment’s database, and eventually push both the updated schema and the new data to the production database.

<Admonition type="info">

Expand Down Expand Up @@ -127,7 +127,7 @@ As an example, take a MongoDB database with two collections, `User` and `Post`.
- `title` field with a type of `string`
- `userId` with a type of `objectID`

On introspection with `db pull`, this is pulled in to the Prisma schema file as follows:
On introspection with `db pull`, this is pulled in to the Prisma Schema as follows:

```prisma file=prisma/schema.prisma showLineNumbers
model Post {
Expand Down Expand Up @@ -356,7 +356,7 @@ For more information on how to set up and manage a MongoDB database, see the [Pr

## Example

To connect to a MongoDB server, configure the [`datasource`](/orm/prisma-schema/overview/data-sources) block in your [Prisma schema file](/orm/prisma-schema):
To connect to a MongoDB server, configure the [`datasource`](/orm/prisma-schema/overview/data-sources) block in your [Prisma Schema](/orm/prisma-schema):

```prisma file=schema.prisma showLineNumbers
datasource db {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ The Microsoft SQL Server data source connector connects Prisma ORM to a [Microso

## Example

To connect to a Microsoft SQL Server database, you need to configure a [`datasource`](/orm/prisma-schema/overview/data-sources) block in your [Prisma schema file](/orm/prisma-schema):
To connect to a Microsoft SQL Server database, you need to configure a [`datasource`](/orm/prisma-schema/overview/data-sources) block in your [Prisma schema](/orm/prisma-schema):

```prisma file=schema.prisma showLineNumbers
datasource db {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ CREATE TABLE public."Post" (
);
```

After introspecting your database with `npx prisma db pull`, you will have a new `Post` model in your `schema.prisma` file:
After introspecting your database with `npx prisma db pull`, you will have a new `Post` model in your Prisma Schema:

```prisma file=schema.prisma showLineNumbers
model Post {
Expand Down Expand Up @@ -94,7 +94,7 @@ For more information on generating database keys, see CockroachDB's [Primary key

## Example

To connect to a CockroachDB database server, you need to configure a [`datasource`](/orm/prisma-schema/overview/data-sources) block in your [Prisma schema file](/orm/prisma-schema):
To connect to a CockroachDB database server, you need to configure a [`datasource`](/orm/prisma-schema/overview/data-sources) block in your [Prisma schema](/orm/prisma-schema):

```prisma file=schema.prisma showLineNumbers
datasource db {
Expand Down
Loading
Loading