CLI Command Reference
prisma init
Bootstraps the service configuration for a new Prisma service. The command launches an interactive CLI wizard by default, helping you to decide where (i.e. to which Prisma server) the service should be deployed later.
If you already know the endpoint, you can pass it using the --endpoint
flag and skip the interactive wizard.
The generated files are:
- prisma.yml
- datamodel.prisma
- docker-compose.yml (optional)
If you provide a directory name as an argument to the command, the generated files will be placed inside a new directory with that name.
Flags
-e, --endpoint The endpoint to be written into prisma.yml
Usage
prisma init DIRNAME
Examples
Create service configuration for Prisma service in a directory called myapp
using the wizard
prisma init myapp
Skip wizard and create service configuration for Prisma service in a directory called myapp
prisma init myapp --endpoint http://localhost:4466/myapp/dev
prisma deploy
Deploys a service configuration to a Prisma service.
Every time you're changing a file deom your service configuration, you need to synchronize these changes with the running Prisma service.
Upon the very first deploy of a service, the command will perform initial data seeding if the seed
property in prisma.yml is provided. You can prevent this by passing the --no-seed
option.
If no endpoint
property is specifed in prisma.yml, the command will prompt you to interactively select a Prisma server as a deployment target for the service. After you selected a Prisma server, the CLI writes the endpoint
into prisma.yml as the default for future deploys. To bring up the interactive prompt again, simply remove the endpoint
property from prisma.yml manually or pass the --new
option.
Usage
prisma deploy [flags]
Flags
-d, --dry-run Perform a dry-run of the deployment
-e, --env-file ENV-FILE Path to .env file to inject env vars
-f, --force Accept data loss caused by schema changes
-j, --json JSON Output
-n, --new Force interactive mode to select the cluster
-w, --watch Watch for changes
--no-seed Disable seed on initial service deploy
Examples
Deploy service configuration in current directory
prisma deploy
Deploy service and interactively select a Prisma server as deployment target:
prisma deploy --new
Deploy service with environment variables specified in .env.prod
prisma deploy --env-file .env.prod
prisma generate
Invokes the generators specified in prisma.yml
. Available generators are:
The following generators are built-into the Prisma CLI:
- Prisma client in JavaScript:
javascript-client
- Prisma client in TypeScript:
typescript-client
- Prisma client in Flow:
flow-client
- Prisma client in Go:
go-client
- GraphQL schema of the Prisma API:
graphql-schema
Usage
prisma generate [flags]
Flags
-e, --env-file ENV-FILE Path to .env file to inject env vars
Examples
Generate the TypeScript client and store the generated files at ./generated/prisma
prisma.yml
:
generate:
- generator: typescript-client
output: ./generated/prisma
prisma generate
Generate the Go client and the GraphQL schema store the generated files at ./generated/prisma
prisma.yml
:
generate:
- generator: go-client
output: ./generated/prisma
- generator: graphql-schema
output: ./generated/prisma
prisma generate
prisma introspect
Creates a datamodel by introspecting the schema of an existing database.
prisma introspect
currently only works for Postgres databases.
The command launches an interactive wizard asking you to provide your database connection details:
- Host: The host of your Postgres server, e.g.
localhost
. - Port: The port where your Postgres server listens, e.g.
5432
. - User & Password: The credentials for your Postgres server.
- Name of existing database: The name of the Postgres database.
- Use SSL (Yes/No): If your database connection is using SSL, you need to select
Yes
, otherwiseNo
. - Name of existing schema: The name of the Postgres schema, e.g.
public
.
Learn more about database introspection with Prisma here.
Usage
prisma introspect
Examples
Introspect an existing database
prisma introspect
Here is a sample interaction where the 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.
prisma info
Display service information:
- Service name
- Service stage
- API endpoints (HTTP and Websocket)
Usage
prisma info
Flags
-e, --env-file ENV-FILE Path to .env file to inject env vars
-j, --json JSON Output
-s, --secret Print secret in JSON output (requires --json option)
Examples
Print information about current service
prisma info
Print information about current service in JSON
prisma info --json
Print information about current service in JSON and include service secret
prisma info --json --secret
The service secret is only printed if both the
--json
and--secret
flags are provided.
prisma token
Generate a new service token. The service token is a JWT that is signed with the service secret.
Usage
prisma token [flags]
Flags
-c, --copy Copy token to clipboard
-e, --env-file ENV-FILE Path to .env file to inject env vars
Examples
Print service token
prisma token
Copy service token to clipboard
prisma token --copy
prisma list
List all deployed services.
Usage
prisma list
Examples
List all deployed services
prisma list
prisma delete
Delete an existing service from the Prisma server its running on.
This command needs to be executed inside the root directory of the Prisma service you want to delete (as the CLI needs access to the service's prisma.yml).
Usage
prisma delete [flags]
Flags
-e, --env-file ENV-FILE Path to .env file to inject env vars
-f, --force Force delete, without confirmation
Examples
Delete an existing service (with confirmation prompt)
prisma delete
Delete an existing service (without confirmation prompt)
prisma delete --force
prisma playground
Opens a GraphQL Playground for the current service.
By default, this opens the Desktop version of the Playground (if installed). The browser-based Playground can be opened by passing the --web
flag.
The Playground is running on port 3000
.
Usage
prisma playground [flags]
Flags
--dotenv DOTENV Path to .env file to inject env vars
-w, --web Open browser-based Playground
Examples
Open Playground (Desktop version, if installed)
prisma playground
Open Playground (browser-based version)
prisma playground --web
prisma seed
Seeds the service with data.
This command expects that the seed
property in prisma.yml is specified.
Usage
prisma seed [flags]
Flags
-e, --env-file ENV-FILE Path to .env file to inject env vars
-r, --reset Reset the service before seeding
Examples
Seed service with initial data
prisma seed
Seed service with initial data after deleting all of the service's data first
prisma seed --reset
prisma import
Imports data into the database of your Prisma service.
The data needs to be formatted according to the Normalized Data Format. For more info, read the Data Import & Export page.
Usage
prisma import [flags]
Flags
-d, --data PATH (required) Path to zip or directory with import data (NDF)
-e, --env-file ENV-FILE Path to .env file to inject env vars
prisma export
Exports your service data to a local zip directory. For more info, read the Data Import & Export page.
Usage
prisma export [flags]
Flags
-e, --env-file ENV-FILE Path to .env file to inject env vars
-p, --path PATH Path to export .zip file
Examples
Export data to file with default name (export-<timestamp>.zip
)
prisma export
Export data to file called mydata.zip
prisma export --path mydata.zip
prisma reset
Delete all service data.
Usage
prisma reset [flags]
Flags
-e, --env-file ENV-FILE Path to .env file to inject env vars
-f, --force Force reset data without confirmation
Examples
Delete all of the service's data (with confirmation prompt).
prisma reset
Delete all of the service's data (without confirmation prompt).
prisma reset --force
prisma login
Authenticate with Prisma Cloud.
This command opens the Prisma Cloud Console where you need to sign up or sign in.
After a successful authentication in the browser, the CLI writes the cloudSessionKey
into ~/.prisma/config.yml
. From there it is used for all subsequent requests made by the CLI against Prisma Cloud.
Note that rather than providing your cloud session key via the --key
flag, you can also set the PRISMA_CLOUD_SESSION_KEY
environment variable, this is especially useful for CI environments.
Usage
prisma login [flags]
Flags
-k, --key KEY Cloud session key
Examples
Authenticate with Prisma Cloud (opens browser)
prisma login
Authenticate with Prisma Cloud by manually passing the cloud session key
prisma login --key KEY
In the above command, the
KEY
placeholder needs to be replaced with the value of your valid cloud session key. You can find thecloudSessionKey
in~/.prisma/config.yml
.
prisma logout
Logout from Prisma Cloud.
This command simply deletes the cloudSessionKey
from ~/.prisma/config.yml
.
Usage
prisma logout
Examples
Log out of Prisma Cloud
prisma logout
prisma console
Opens the Prisma Cloud Console in the browser.
Usage
prisma console
Examples
Open the Prisma Cloud Console in the browser
prisma console
prisma account
Displays account information of the authenticated Prisma Cloud user (based on the cloudSessionKey
in ~/.prisma/config.yml
).
The displayed information includes:
- Username
- Email address
Usage
prisma account
Examples
Display account information of the authenticated Prisma Cloud user
prisma account