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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added deprecation warning for prisma introspect command #2134

Merged
merged 4 commits into from Aug 11, 2021
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Expand Up @@ -143,6 +143,13 @@ Run the following command to introspect your database:
npx prisma introspect
```

<Admonition type="warning">

**Deprecation warning** <br />
From Prisma 3.0.0 onwards, the `prisma introspect` command will be deprecated and replaced with the [`prisma db pull`](../../../../../reference/api-reference/command-reference#db-pull) command.

</Admonition>

This commands 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:
Expand Down
Expand Up @@ -236,6 +236,13 @@ Here is an overview of the main workflow:
1. Run `prisma introspect` to introspect the database and add application models to the Prisma schema
1. Run `prisma generate` to update your Prisma Client API

<Admonition type="warning">

**Deprecation warning** <br />
From Prisma 3.0.0 onwards, the `prisma introspect` command will be deprecated and replaced with the [`prisma db pull`](../../../reference/api-reference/command-reference#db-pull) command.

</Admonition>

### Using Prisma Client and Prisma Migrate

<Admonition type="warning">
Expand Down
Expand Up @@ -314,6 +314,13 @@ generator client {
3. (Optional) Customize [field and model mappings](../../components/prisma-schema/data-model#mapping-model-names-to-tables-or-collections) between Prisma Client and the database.
4. Run `prisma generate`.

<Admonition type="warning">

**Deprecation warning** <br />
From Prisma 3.0.0 onwards, the `prisma introspect` command will be deprecated and replaced with the [`prisma db pull`](../../../../reference/api-reference/command-reference#db-pull) command.

</Admonition>

Prisma will generate Prisma Client inside the `node_modules` folder, from which it can be imported in your application. For more extensive usage documentation, see the [Prisma Client API](../../components/prisma-client) docs.

To summarize, Prisma Client can be integrated into projects with an existing database and tooling as part of a parallel adoption strategy. New projects will use a different workflow detailed next.
Expand Down
Expand Up @@ -190,6 +190,13 @@ You can "rename" fields and models that are used in the Prisma Client by mapping

_After_ you introspected your database with `prisma introspect`, you can manually adjust the resulting Prisma schema as follows:

<Admonition type="warning">

**Deprecation warning** <br />
From Prisma 3.0.0 onwards, the `prisma introspect` command will be deprecated and replaced with the [`prisma db pull`](../../../../reference/api-reference/command-reference#db-pull) command.

</Admonition>

```prisma
model Category {
category_id Int @default(autoincrement()) @id
Expand Down
7 changes: 7 additions & 0 deletions content/200-concepts/100-components/04-introspection.mdx
Expand Up @@ -42,6 +42,13 @@ You can learn more about how Prisma maps types from the database to the types av

## The `prisma introspect` command
molebox marked this conversation as resolved.
Show resolved Hide resolved

<Admonition type="warning">

**Deprecation warning** <br />
From Prisma 3.0.0 onwards, the `prisma introspect` command will be deprecated and replaced with the [`prisma db pull`](../../../reference/api-reference/command-reference#db-pull) command.

</Admonition>

You can introspect your database using the `prisma introspect` command of the [Prisma CLI](prisma-cli/installation). Note that using this command requires your [connection URL](../../reference/database-reference/connection-urls) to be set in your Prisma schema!

Here's a high-level overview of the steps that `prisma introspect` performs internally:
Expand Down
Expand Up @@ -168,6 +168,13 @@ To connect to your Microsoft SQL Server database:

1. Introspect your database to validate your connection URL - the CLI will throw a `P4001` error because your database is empty:

<Admonition type="warning">

**Deprecation warning** <br />
From Prisma 3.0.0 onwards, the `prisma introspect` command will be deprecated and replaced with the [`prisma db pull`](../../../../reference/api-reference/command-reference#db-pull) command.

</Admonition>

<CodeWithResult>

<cmd>
Expand Down Expand Up @@ -351,6 +358,13 @@ To create tables SQL Server Management Studio:

## Introspect your database with Prisma

<Admonition type="warning">

**Deprecation warning** <br />
From Prisma 3.0.0 onwards, the `prisma introspect` command will be deprecated and replaced with the [`prisma db pull`](../../../../reference/api-reference/command-reference#db-pull) command.

</Admonition>

As a next step, you will introspect your database. The result of the introspection will be a [data model](../../../components/prisma-schema/data-model) inside your Prisma schema.

1. Run the following command to introspect your database:
Expand Down
Expand Up @@ -25,6 +25,13 @@ Production databases and any other database that cannot be reset should be [base

### Introspect to create or update your Prisma schema

<Admonition type="warning">

**Deprecation warning** <br />
From Prisma 3.0.0 onwards, the `prisma introspect` command will be deprecated and replaced with the [`prisma db pull`](../../../reference/api-reference/command-reference#db-pull) command.

</Admonition>

Make sure your Prisma schema is in sync with your database schema. This should already be true if you are using a previous version of Prisma Migrate.

1. Introspect the database to make sure that your Prisma schema is up-to-date:
Expand Down
Expand Up @@ -68,6 +68,13 @@ If you made manual changes to the database that you want to keep, you can:

1. Introspect the database:

<Admonition type="warning">

**Deprecation warning** <br />
From Prisma 3.0.0 onwards, the `prisma introspect` command will be deprecated and replaced with the [`prisma db pull`](../../../reference/api-reference/command-reference#db-pull) command.

</Admonition>

```terminal
npx prisma introspect
```
Expand Down
Expand Up @@ -257,6 +257,13 @@ Since `TheLastPost` records can only ever reference existing `TheLastUser` recor

## 7. Introspect your database with Prisma

<Admonition type="warning">

**Deprecation warning** <br />
From Prisma 3.0.0 onwards, the `prisma introspect` command will be deprecated and replaced with the [`prisma db pull`](../../../../reference/api-reference/command-reference#db-pull) command.

</Admonition>

In the previous sections, you created five times two tables with foreign key constraints:

- The table `Post` uses `RESTRICT` behavior on the foreign key column `authorId` which points to the `User` table
Expand Down
Expand Up @@ -248,6 +248,13 @@ mysql -e 'DROP TABLE `CascadingDeletesDemo`.`TheLastUser`;'

## 6. Introspect your database with Prisma

<Admonition type="warning">

**Deprecation warning** <br />
From Prisma 3.0.0 onwards, the `prisma introspect` command will be deprecated and replaced with the [`prisma db pull`](../../../../reference/api-reference/command-reference#db-pull) command.

</Admonition>

In the previous sections, you created two tables with foreign key constraints for each of the following three scenarios:

- The table `Post` uses `RESTRICT` action on the foreign key column `authorId` which points to the `User` table. This is identical to the default behavior and the `NO ACTION` behavior.
Expand Down
Expand Up @@ -257,6 +257,13 @@ Since `TheLastPost` records can only ever reference existing `TheLastUser` recor

## 7. Introspect your database with Prisma

<Admonition type="warning">

**Deprecation warning** <br />
From Prisma 3.0.0 onwards, the `prisma introspect` command will be deprecated and replaced with the [`prisma db pull`](../../../../reference/api-reference/command-reference#db-pull) command.

</Admonition>

In the previous sections, you created five times two tables with foreign key constraints:

- The table `Post` uses `RESTRICT` action on the foreign key column `authorId` which points to the `User` table
Expand Down
Expand Up @@ -234,6 +234,13 @@ Congratulations, you just created a table called `lastproduct` in the database w

## 6. Introspect your database with Prisma

<Admonition type="warning">

**Deprecation warning** <br />
From Prisma 3.0.0 onwards, the `prisma introspect` command will be deprecated and replaced with the [`prisma db pull`](../../../../reference/api-reference/command-reference#db-pull) command.

</Admonition>

In the previous sections, you created four tables with different check constraints:

- The `product` table has a check constraint that ensures that the value of `price` is never less than `0.01` and enver exactly `1240.00`.
Expand Down
Expand Up @@ -310,6 +310,13 @@ In this section you will create a view named `Draft`. The `Draft` view represent

## 4. Introspect your database with Prisma

<Admonition type="warning">

**Deprecation warning** <br />
From Prisma 3.0.0 onwards, the `prisma introspect` command will be deprecated and replaced with the [`prisma db pull`](../../../reference/api-reference/command-reference#db-pull) command.

</Admonition>

In this section you'll introspect your database to generate the Prisma models for the tables that you created.

> **Note**: You will manually add the `Draft` view to the Prisma schema in a later step.
Expand Down
Expand Up @@ -128,6 +128,13 @@ The following steps show how to use the `dotenv-cli` package to use an alternati
dotenv -e .env3 -- npx prisma introspect
```

<Admonition type="warning">

**Deprecation warning** <br />
From Prisma 3.0.0 onwards, the `prisma introspect` command will be deprecated and replaced with the [`prisma db pull`](../../../reference/api-reference/command-reference#db-pull) command.

</Admonition>

> **Note:** dotenv doesn't pass the flags to the Prisma command by default, this is why the command includes two dashes `--` before `prisma`, making it possible to use flags like `--force`, `--schema` or `--preview-feature`.

### Using <inlinecode>dotenv</inlinecode> via application code
Expand Down
Expand Up @@ -106,6 +106,13 @@ DATABASE_URL=postgresql://test:test@localhost:5432/test?schema=public

When you run a command that needs access to the database defined via the `datasource` block (for example, `prisma introspect`), the Prisma CLI automatically loads the `DATABASE_URL` environment variables from the `.env` file and makes it available to the CLI.

<Admonition type="warning">

**Deprecation warning** <br />
From Prisma 3.0.0 onwards, the `prisma introspect` command will be deprecated and replaced with the [`prisma db pull`](../../../../reference/api-reference/command-reference#db-pull) command.

</Admonition>

### Using environment variables in your code

If you want environment variables to be evaluated at runtime, you need to load them manually in your application code (for example, by using [`dotenv`](https://github.com/motdotla/dotenv)):
Expand Down
Expand Up @@ -53,6 +53,13 @@ This guide starts with an empty database created with plain SQL and looks as fol
1. Run `prisma introspect` locally which will introspect and populate the `schema.prisma` with models based on the database schema.
1. Run `prisma generate` which will generate Prisma Client based on the Prisma schema.

<Admonition type="warning">

**Deprecation warning** <br />
From Prisma 3.0.0 onwards, the `prisma introspect` command will be deprecated and replaced with the [`prisma db pull`](../../../reference/api-reference/command-reference#db-pull) command.

</Admonition>

## 1. Download the example

Open your terminal and navigate to a location of your choice. Create the directory that will hold the application code and download the example code:
Expand Down Expand Up @@ -143,6 +150,13 @@ Congratulations, you have successfully created the database schema.

## 5. Introspect the database

<Admonition type="warning">

**Deprecation warning** <br />
From Prisma 3.0.0 onwards, the `prisma introspect` command will be deprecated and replaced with the [`prisma db pull`](../../../reference/api-reference/command-reference#db-pull) command.

</Admonition>

Introspect the database with the Prisma CLI:

```terminal
Expand Down
Expand Up @@ -46,6 +46,13 @@ This guide starts with an empty database created with plain SQL and looks as fol
1. Run `prisma introspect` locally which will introspect and populate the `schema.prisma` with models based on the database schema.
1. Run `prisma generate` which will generate Prisma Client based on the Prisma schema.

<Admonition type="warning">

**Deprecation warning** <br />
From Prisma 3.0.0 onwards, the `prisma introspect` command will be deprecated and replaced with the [`prisma db pull`](../../../reference/api-reference/command-reference#db-pull) command.

</Admonition>

## 1. Fork the `deployment-example-netlify` repository

Go to [`deployment-example-netlify`](https://github.com/prisma/deployment-example-netlify) and **Fork** the repository by clicking on the fork button on the top right corner:
Expand Down Expand Up @@ -124,6 +131,13 @@ Congratulations, you have successfully created the database schema.

## 5. Introspect the database

<Admonition type="warning">

**Deprecation warning** <br />
From Prisma 3.0.0 onwards, the `prisma introspect` command will be deprecated and replaced with the [`prisma db pull`](../../../reference/api-reference/command-reference#db-pull) command.

</Admonition>

Introspect the database with the Prisma CLI:

```terminal
Expand Down
Expand Up @@ -26,6 +26,13 @@ If you started a development environment based on an initial introspection of a

## Upgrade path for introspection only users

<Admonition type="warning">

**Deprecation warning** <br />
From Prisma 3.0.0 onwards, the `prisma introspect` command will be deprecated and replaced with the [`prisma db pull`](../../../reference/api-reference/command-reference#db-pull) command.

</Admonition>

Use the following guide if you use introspection only.

1. Enable the `namedConstraints` Preview:
Expand Down
Expand Up @@ -90,6 +90,13 @@ For the **initial setup**:
1. You set up Prisma 2 by installing the Prisma 2 CLI and running `npx prisma init`.
1. You connect to your database and introspect it with `npx prisma introspect`.

<Admonition type="warning">

**Deprecation warning** <br />
From Prisma 3.0.0 onwards, the `prisma introspect` command will be deprecated and replaced with the [`prisma db pull`](../../../reference/api-reference/command-reference#db-pull) command.

</Admonition>

![Prisma CLI introspection flow](https://imgur.com/UiJCG4L.png)

For **fixing the schema incompatibilities**:
Expand Down
Expand Up @@ -1060,6 +1060,13 @@ In this section, you'll update your Prisma schema with another introspection rou
npx prisma introspect
```

<Admonition type="warning">

**Deprecation warning** <br />
From Prisma 3.0.0 onwards, the `prisma introspect` command will be deprecated and replaced with the [`prisma db pull`](../../../reference/api-reference/command-reference#db-pull) command.

</Admonition>

This time, the resulting Prisma schema looks as follows:

```prisma file=schema.prisma
Expand Down
Expand Up @@ -247,6 +247,13 @@ npm install prisma --save-dev

## Step 2. Introspect your database

<Admonition type="warning">

**Deprecation warning** <br />
From Prisma 3.0.0 onwards, the `prisma introspect` command will be deprecated and replaced with the [`prisma db pull`](../../reference/api-reference/command-reference#db-pull) command.

</Admonition>

### 2.1. Set up Prisma

Before you can introspect your database, you need to set up your [Prisma schema](../../concepts/components/prisma-schema) and connect Prisma to your database. Run the following command in your terminal to create a basic Prisma schema file:
Expand Down
Expand Up @@ -179,6 +179,13 @@ npm install prisma --save-dev

## Step 2. Introspect your database

<Admonition type="warning">

**Deprecation warning** <br />
From Prisma 3.0.0 onwards, the `prisma introspect` command will be deprecated and replaced with the [`prisma db pull`](../../reference/api-reference/command-reference#db-pull) command.

</Admonition>

### 2.1. Set up Prisma

Before you can introspect your database, you need to set up your [Prisma schema](../../concepts/components/prisma-schema) and connect Prisma to your database. Run the following command in your terminal to create a basic Prisma schema file:
Expand Down
Expand Up @@ -175,6 +175,13 @@ CREATE UNIQUE INDEX "TheLastUser_firstName_lastName_unique_constraint" ON "TheLa

## 6. Introspect your database with Prisma

<Admonition type="warning">

**Deprecation warning** <br />
From Prisma 3.0.0 onwards, the `prisma introspect` command will be deprecated and replaced with the [`prisma db pull`](../../../../reference/api-reference/command-reference#db-pull) command.

</Admonition>

In the previous sections, you created four tables with unique constraints:

- The table `User` has a singe-column unique constraint and index on the `email` column
Expand Down
Expand Up @@ -192,6 +192,13 @@ CREATE UNIQUE INDEX `TheLastUser_firstName_lastName_unique_constraint` ON `Uniqu

## 6. Introspect your database with Prisma

<Admonition type="warning">

**Deprecation warning** <br />
From Prisma 3.0.0 onwards, the `prisma introspect` command will be deprecated and replaced with the [`prisma db pull`](../../../../reference/api-reference/command-reference#db-pull) command.

</Admonition>

In the previous sections, you created four tables with unique constraints:

- The table `User` has a singe-column unique constraint and index on the `email` column
Expand Down
Expand Up @@ -115,6 +115,13 @@ CREATE UNIQUE INDEX "sqlite_autoindex_AnotherUser_1" ON "AnotherUser"("firstName

## 4. Introspect your database with Prisma

<Admonition type="warning">

**Deprecation warning** <br />
From Prisma 3.0.0 onwards, the `prisma introspect` command will be deprecated and replaced with the [`prisma db pull`](../../../../reference/api-reference/command-reference#db-pull) command.

</Admonition>

In the previous sections, you created two tables with unique constraints:

- The table `User` has a singe-column unique constraint and index on the `email` column
Expand Down