Prisma CLI & ConfigurationCLI Command Reference

prisma introspect

$ prisma introspect

Creates a datamodel by introspecting the schema of an existing database.

prisma introspect currently only works for PostgreSQL and MongoDB databases.

Learn more about database introspection with Prisma here.


prisma introspect


Introspect an existing database

prisma introspect

Here is a sample interaction where the PostgreSQL database connection details are provided through the wizard:

? What kind of database do you want to introspect? Postgres
? Enter database host localhost
? Enter database port 5432
? Enter database user prisma
? Enter database password ****
? Enter name of existing database prisma-db
? Enter name of existing schema public

Introspecting database 402ms
Created datamodel mapping based on 7 database tables.

Created 1 new file:

  datamodel-[TIMESTAMP].graphql    GraphQL SDL-based datamodel (derived from existing database)

The generated datamodel file will contain a timestamp in its name to avoid overriding your existing datamodel.prisma file.