Skip to content

Commit

Permalink
add info about --url argument to introspection docs
Browse files Browse the repository at this point in the history
  • Loading branch information
nikolasburk committed Jan 13, 2020
1 parent 75056db commit 5423f7a
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion docs/introspection.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,17 @@

When working with an existing database, the first step towards using the Prisma Framework is to obtain a [Prisma schema](./prisma-schema-file.md) that matches your database schema (or a subset of your database schema). You can create this schema file manually and write out all the required [models](./data-modeling.md#models) by hand, or use Prisma's _introspection_ feature to automatically generate your Prisma schema.

Prisma lets you introspect your database to derive a data model definition from the current database schema. Introspection is available via two CLI commands:
Prisma lets you introspect your database to derive a data model definition from the current database schema. Introspection is available via either of two CLI commands:

- `prisma2 init`: Interactive wizard that helps you connect to a database and introspect it. Typically used when starting to use Prisma with an existing database.
- `prisma2 introspect`: Assumes Prisma is already connected to your database and (re)introspects it for you. Typically used in [Photon-only](./photon/use-only-photon.md) projects where migrations are performed not via Lift, so the data model needs to be updated manually after each database schema change.

Note that `prisma2 introspect` requires the connection string for the database you want to introspect. Therefore, you either need to run the command inside of a directory that contains a [Prisma schema](./prisma-schema-file.md) with a valid `datasource` definition (which contains the connection string) or pass the `--url` argument, e.g.:

```
prisma2 introspect --url postgresql://janedoe:mypassword42@localhost:5432/mydb
```

## Introspecting only a subset of your database schema

This is [not yet supported by Prisma](https://github.com/prisma/prisma2/issues/807). However, you can achieve this by creating a new database user that only has access to the tables which you'd like to see represented in your Prisma schema, and then perform the introspection using that user. The introspection will then only include the tables the new user has access to.
Expand Down

0 comments on commit 5423f7a

Please sign in to comment.