From e19d6a8507d7105920115da1a2270fb903b9a6d1 Mon Sep 17 00:00:00 2001 From: ruheni Date: Tue, 25 Apr 2023 19:01:55 +0200 Subject: [PATCH 01/14] chore: reorganize Prisma CLI reference --- .../170-baseline-your-database.mdx | 2 +- .../275-evolve-your-schema.mdx | 2 +- .../250-should-you-use-prisma.mdx | 4 +- .../01-prisma-schema/06-relations/index.mdx | 2 +- .../100-components/01-prisma-schema/index.mdx | 4 +- .../03-prisma-migrate/010-mental-model.mdx | 10 +- .../03-prisma-migrate/100-legacy-migrate.mdx | 2 +- .../03-prisma-migrate/150-db-push.mdx | 2 +- .../03-prisma-migrate/200-shadow-database.mdx | 2 +- .../index.mdx => 05-prisma-cli.mdx} | 2 +- .../080-cli-preview-features.mdx | 4 +- .../175-squashing-migrations.mdx | 4 +- .../180-generating-down-migrations.mdx | 4 +- .../200-troubleshooting-development.mdx | 2 +- .../index.mdx | 2 +- .../400-prototyping-schema-db-push.mdx | 2 +- .../800-production-troubleshooting.mdx | 4 +- .../150-deploying-to-azure-functions.mdx | 2 +- ...y-database-changes-with-prisma-migrate.mdx | 2 +- .../100-named-constraints.mdx | 2 +- .../prisma-cli}/01-installation.mdx | 0 .../02-command-reference.mdx} | 0 .../200-api-reference/prisma-cli/index.mdx | 19 ++++ content/600-about/100-prisma/40-faq.mdx | 2 +- .../20-style-guide/02-word-choice.mdx | 2 +- .../700-prisma-cli-with-data-proxy.mdx | 4 +- .../200-projects/100-create.mdx | 2 +- vercel.json | 102 +----------------- 28 files changed, 55 insertions(+), 136 deletions(-) rename content/200-concepts/100-components/{05-prisma-cli/index.mdx => 05-prisma-cli.mdx} (79%) rename content/{200-concepts/100-components/05-prisma-cli => 400-reference/200-api-reference/prisma-cli}/01-installation.mdx (100%) rename content/400-reference/200-api-reference/{200-command-reference.mdx => prisma-cli/02-command-reference.mdx} (100%) create mode 100644 content/400-reference/200-api-reference/prisma-cli/index.mdx diff --git a/content/100-getting-started/02-setup-prisma/200-add-to-existing-project/110-relational-databases/170-baseline-your-database.mdx b/content/100-getting-started/02-setup-prisma/200-add-to-existing-project/110-relational-databases/170-baseline-your-database.mdx index b3325029b9..6df5bfd25a 100644 --- a/content/100-getting-started/02-setup-prisma/200-add-to-existing-project/110-relational-databases/170-baseline-your-database.mdx +++ b/content/100-getting-started/02-setup-prisma/200-add-to-existing-project/110-relational-databases/170-baseline-your-database.mdx @@ -13,7 +13,7 @@ To use Prisma Migrate with the database you introspected in the last section, yo Baselining refers to initializing your migration history for a database that might already contain data and **cannot be reset**, such as your production database. Baselining tells Prisma Migrate to assume that one or more migrations have already been applied to your database. -To baseline your database, use [`prisma migrate diff`](/reference/api-reference/command-reference#migrate-diff) to compare your schema and database, and save the output into a SQL file. +To baseline your database, use [`prisma migrate diff`](/reference/api-reference/prisma-cli/command-reference#migrate-diff) to compare your schema and database, and save the output into a SQL file. First, create a `migrations` directory and add a directory inside with your preferred name for the migration. In this example, we will use `0_init` as the migration name: diff --git a/content/100-getting-started/02-setup-prisma/200-add-to-existing-project/110-relational-databases/275-evolve-your-schema.mdx b/content/100-getting-started/02-setup-prisma/200-add-to-existing-project/110-relational-databases/275-evolve-your-schema.mdx index 1c082693de..ea3e3758ab 100644 --- a/content/100-getting-started/02-setup-prisma/200-add-to-existing-project/110-relational-databases/275-evolve-your-schema.mdx +++ b/content/100-getting-started/02-setup-prisma/200-add-to-existing-project/110-relational-databases/275-evolve-your-schema.mdx @@ -9,7 +9,7 @@ toc: false ## Add a `Tag` model to your schema -In this section, you will evolve your Prisma schema and then generate and apply the migration to your database with [`prisma migrate dev`](/reference/api-reference/command-reference#migrate-dev). +In this section, you will evolve your Prisma schema and then generate and apply the migration to your database with [`prisma migrate dev`](/reference/api-reference/prisma-cli/command-reference#migrate-dev). For the purpose of this guide, we'll make the following changes to the Prisma schema: diff --git a/content/200-concepts/050-overview/250-should-you-use-prisma.mdx b/content/200-concepts/050-overview/250-should-you-use-prisma.mdx index b3d914b694..77b48b573a 100644 --- a/content/200-concepts/050-overview/250-should-you-use-prisma.mdx +++ b/content/200-concepts/050-overview/250-should-you-use-prisma.mdx @@ -80,8 +80,8 @@ Prisma is a lot more than "just another ORM". We are building a database toolkit - querying (with [Prisma Client](/concepts/components/prisma-client)) - data modeling (in the [Prisma schema](/concepts/components/prisma-schema)) - migrations (with [Prisma Migrate](/concepts/components/prisma-migrate)) -- prototyping (via [`prisma db push`](/reference/api-reference/command-reference#db-push)) -- seeding (via [`prisma db seed`](/reference/api-reference/command-reference#db-seed)) +- prototyping (via [`prisma db push`](/reference/api-reference/prisma-cli/command-reference#db-push)) +- seeding (via [`prisma db seed`](/reference/api-reference/prisma-cli/command-reference#db-seed)) - visual viewing and editing (with [Prisma Studio](https://www.prisma.io/studio)) ### ... you value type-safety diff --git a/content/200-concepts/100-components/01-prisma-schema/06-relations/index.mdx b/content/200-concepts/100-components/01-prisma-schema/06-relations/index.mdx index 344db4e901..61b6bdbf7b 100644 --- a/content/200-concepts/100-components/01-prisma-schema/06-relations/index.mdx +++ b/content/200-concepts/100-components/01-prisma-schema/06-relations/index.mdx @@ -574,7 +574,7 @@ For **implicit m-n-relations**, both relation fields are virtual since neither o ![](../../../../doc-images/unused/DxuOs88.png) -Prisma always requires both sides of a relation to be present, this means that one virtual relation field always needs to be added per relation. When [formatting the Prisma schema](/reference/api-reference/command-reference#format), the formatter automatically inserts any missing virtual relation fields for you to save some typing work. +Prisma always requires both sides of a relation to be present, this means that one virtual relation field always needs to be added per relation. When [formatting the Prisma schema](/reference/api-reference/prisma-cli/command-reference#format), the formatter automatically inserts any missing virtual relation fields for you to save some typing work. Virtual relation fields are also present in the generated [Prisma CLI](/concepts/components/prisma-client) which makes working with relations more convenient as you can traverse relationships in your code in both directions, for example: diff --git a/content/200-concepts/100-components/01-prisma-schema/index.mdx b/content/200-concepts/100-components/01-prisma-schema/index.mdx index 7848c4aeaf..f994107a2c 100644 --- a/content/200-concepts/100-components/01-prisma-schema/index.mdx +++ b/content/200-concepts/100-components/01-prisma-schema/index.mdx @@ -148,7 +148,7 @@ model User { The Prisma CLI looks for the Prisma schema file in the following locations, in the following order: -1. The location specified by the [`--schema` flag](/reference/api-reference/command-reference), which is available when you `introspect`, `generate`, `migrate`, and `studio`: +1. The location specified by the [`--schema` flag](/reference/api-reference/prisma-cli/command-reference), which is available when you `introspect`, `generate`, `migrate`, and `studio`: ```terminal prisma generate --schema=./alternative/schema.prisma @@ -232,7 +232,7 @@ model Customer {} Prisma supports formatting `.prisma` files automatically. There are two ways to format `.prisma` files: -- Run the [`prisma format`](/reference/api-reference/command-reference#format) command. +- Run the [`prisma format`](/reference/api-reference/prisma-cli/command-reference#format) command. - Install the [Prisma VS Code extension](https://marketplace.visualstudio.com/items?itemName=Prisma.prisma) and invoke the [VS Code format action](https://code.visualstudio.com/docs/editor/codebasics#_formatting) - manually or on save. There are no configuration options - [formatting rules](#formatting-rules) are fixed (similar to Golang's `gofmt` but unlike Javascript's `prettier`): diff --git a/content/200-concepts/100-components/03-prisma-migrate/010-mental-model.mdx b/content/200-concepts/100-components/03-prisma-migrate/010-mental-model.mdx index 113dbc3693..165c523923 100644 --- a/content/200-concepts/100-components/03-prisma-migrate/010-mental-model.mdx +++ b/content/200-concepts/100-components/03-prisma-migrate/010-mental-model.mdx @@ -96,7 +96,7 @@ This section describes how you can evolve your database schema in different envi #### Track your migration history with prisma migrate dev -The [`prisma migrate dev`](/reference/api-reference/command-reference#migrate-dev) command allows you to track the changes you make to your database. The `prisma migrate dev` command automatically generates SQL migration files (saved in `/prisma/migrations`) and applies them to the database. When a migration is applied to the database, the migrations table (`_prisma_migrations`) in your database is also updated. +The [`prisma migrate dev`](/reference/api-reference/prisma-cli/command-reference#migrate-dev) command allows you to track the changes you make to your database. The `prisma migrate dev` command automatically generates SQL migration files (saved in `/prisma/migrations`) and applies them to the database. When a migration is applied to the database, the migrations table (`_prisma_migrations`) in your database is also updated. ![Prisma Migrate dev flow](./mental-model-illustrations/prisma-migrate-dev-flow.png) @@ -129,7 +129,7 @@ If `prisma migrate dev` detects a schema drift or a migration history conflict, A schema drift occurs when the expected database schema is different from what is in the migration history. For example, this can occur when you manually update the database schema without also updating the Prisma schema and `prisma/migrations` accordingly. -For such instances, you can use the [`prisma migrate diff`](/reference/api-reference/command-reference#migrate-diff) command to compare your migration history and revert changes made to your database schema. +For such instances, you can use the [`prisma migrate diff`](/reference/api-reference/prisma-cli/command-reference#migrate-diff) command to compare your migration history and revert changes made to your database schema. ![Revert database schema with `migrate diff`](./mental-model-illustrations/prisma-migrate-diff-flow.png) @@ -138,11 +138,11 @@ You can use `migrate diff` to generate the SQL that either: - Reverts the changes made in the database schema to synchronize it with the current Prisma schema - Moves your database schema forward to apply missing changes from the Prisma schema and `/migrations` -You can then apply the changes to your database using [`prisma db execute`](/reference/api-reference/command-reference#db-execute) command. +You can then apply the changes to your database using [`prisma db execute`](/reference/api-reference/prisma-cli/command-reference#db-execute) command. #### Prototype your schema -The [`prisma db push`](/reference/api-reference/command-reference#db-push) command allows you to sync your Prisma schema and database schema without persisting a migration (`/prisma/migrations`). The `prisma db push` command tracks the state of the database using the following pieces of state: +The [`prisma db push`](/reference/api-reference/prisma-cli/command-reference#db-push) command allows you to sync your Prisma schema and database schema without persisting a migration (`/prisma/migrations`). The `prisma db push` command tracks the state of the database using the following pieces of state: - the Prisma schema - the database schema @@ -163,7 +163,7 @@ If the `prisma db push` command detects destructive change to your database sche #### Sync your migration histories -The [`prisma migrate deploy`](/reference/api-reference/command-reference#migrate-deploy) command allows you to sync your migration history from your development environment with your database in your **staging or production environment**. +The [`prisma migrate deploy`](/reference/api-reference/prisma-cli/command-reference#migrate-deploy) command allows you to sync your migration history from your development environment with your database in your **staging or production environment**. Under the hood, the `migrate deploy` command: diff --git a/content/200-concepts/100-components/03-prisma-migrate/100-legacy-migrate.mdx b/content/200-concepts/100-components/03-prisma-migrate/100-legacy-migrate.mdx index 5d4fa8e20f..b475381667 100644 --- a/content/200-concepts/100-components/03-prisma-migrate/100-legacy-migrate.mdx +++ b/content/200-concepts/100-components/03-prisma-migrate/100-legacy-migrate.mdx @@ -18,7 +18,7 @@ Legacy Prisma Migrate is a tool that lets you _change your database schema_, e.g ### Legacy Prisma Migrate vs the `db push` command -If you want to prototype or iterate on a schema design in a development environment, consider the [`db push` command](/reference/api-reference/command-reference#db-push). +If you want to prototype or iterate on a schema design in a development environment, consider the [`db push` command](/reference/api-reference/prisma-cli/command-reference#db-push). ### Legacy Prisma Migrate vs SQL migrations diff --git a/content/200-concepts/100-components/03-prisma-migrate/150-db-push.mdx b/content/200-concepts/100-components/03-prisma-migrate/150-db-push.mdx index 6a9400bf91..ece919cd28 100644 --- a/content/200-concepts/100-components/03-prisma-migrate/150-db-push.mdx +++ b/content/200-concepts/100-components/03-prisma-migrate/150-db-push.mdx @@ -7,7 +7,7 @@ codeStyle: false -The Prisma CLI has a dedicated command for prototyping schemas: [`db push`](/reference/api-reference/command-reference#db-push) +The Prisma CLI has a dedicated command for prototyping schemas: [`db push`](/reference/api-reference/prisma-cli/command-reference#db-push) `db push` uses the same engine as Prisma Migrate to synchronize your Prisma schema with your database schema. The `db push` command: diff --git a/content/200-concepts/100-components/03-prisma-migrate/200-shadow-database.mdx b/content/200-concepts/100-components/03-prisma-migrate/200-shadow-database.mdx index 3cddfd081d..18442bca06 100644 --- a/content/200-concepts/100-components/03-prisma-migrate/200-shadow-database.mdx +++ b/content/200-concepts/100-components/03-prisma-migrate/200-shadow-database.mdx @@ -126,6 +126,6 @@ To resolve this error: - If you are working locally, we recommend that you update the database user's privileges. - If you are developing against a cloud-based database (for example, on Heroku and Digital Ocean) see: [Cloud-hosted shadow databases](#cloud-hosted-shadow-databases-must-be-created-manually). -- If you are developing against a cloud-based database (for example, on Heroku and Digital Ocean) and are currently **prototyping** such that you don't care about generated migration files and only need to apply your Prisma data model to the database schema, you can run [`prisma db push`](/reference/api-reference/command-reference#db) instead of the `prisma migrate dev` command. +- If you are developing against a cloud-based database (for example, on Heroku and Digital Ocean) and are currently **prototyping** such that you don't care about generated migration files and only need to apply your Prisma data model to the database schema, you can run [`prisma db push`](/reference/api-reference/prisma-cli/command-reference#db) instead of the `prisma migrate dev` command. > **Important**: The shadow database is _only_ required in a development environment (specifically for the `prisma migrate dev` command) - you **do not** need to make any changes to your production environment. diff --git a/content/200-concepts/100-components/05-prisma-cli/index.mdx b/content/200-concepts/100-components/05-prisma-cli.mdx similarity index 79% rename from content/200-concepts/100-components/05-prisma-cli/index.mdx rename to content/200-concepts/100-components/05-prisma-cli.mdx index 2e4c9e5710..e5afc5533f 100644 --- a/content/200-concepts/100-components/05-prisma-cli/index.mdx +++ b/content/200-concepts/100-components/05-prisma-cli.mdx @@ -15,4 +15,4 @@ The Prisma command line interface (CLI) is the primary way to interact with your ## Prisma CLI command reference -See [Prisma CLI command reference](/reference/api-reference/command-reference) for a complete list of commands. +See [Prisma CLI command reference](/reference/api-reference/prisma-cli/command-reference) for a complete list of commands. diff --git a/content/200-concepts/100-components/250-preview-features/080-cli-preview-features.mdx b/content/200-concepts/100-components/250-preview-features/080-cli-preview-features.mdx index 6b763cd27e..0ecb5c381e 100644 --- a/content/200-concepts/100-components/250-preview-features/080-cli-preview-features.mdx +++ b/content/200-concepts/100-components/250-preview-features/080-cli-preview-features.mdx @@ -19,8 +19,8 @@ There are currently no [Preview](/about/prisma/releases#preview) features for Pr