Prisma 2 CLI currently requires Node 10 (or higher).
npm install -g prisma2
yarn global add prisma2
When installing Prisma 2 CLI, a postinstall
hook is being executed. It downloads Prisma 2's query and migration engine binaries. The query engine contains the Prisma schema parser which is used by the prisma2 init
and the prism2 generate
commands. The migration engine is used by all prisma2 migrate
commands.
Prisma 2 CLI supports custom HTTP proxies. This is particularly relevant when being behind a corporate firewall.
To activate the proxy, provide the environment variables HTTP_PROXY
and/or HTTPS_PROXY
. The behavior is very similar to how the npm
CLI handles this.
The following environment variables can be provided:
HTTP_PROXY
orhttp_proxy
: Proxy URL for http traffic, for examplehttp://localhost:8080
HTTPS_PROXY
orhttps_proxy
: Proxy URL for https traffic, for examplehttps://localhost:8080
To get a local proxy, you can also use the
proxy
module:
Sets up Prisma (i.e., Prisma Client JS and/or Lift) via an interactive wizard. You can specify your database connection and/or create a new database to work with. For a list with currently supported databases, see the this page. The wizard also allows you to derive a Prisma schema file from your existing database.
Invokes all generators defined in the Prisma schema file. For example, this creates the Prisma Client JS to interact with the underlying database. Read more about Prisma Client JS and its capabilities here.
Introspects the database and generates a data model from it. Basically, it analyzes your (already existing) database and automatically creates the Prisma schema file for you. This is useful, if you already have an existing application and want to start using Prisma 2. Note that this command synchronizes your Prisma schema file according to your database structure; typically if you're not using Lift to migrate your database.
⚠️ Prisma's migration functionality is currently in an experimental state. When using any of the commands below, you need to explicitly opt-in to that functionality via an--experimental
flag that needs to be passed to a command, e.g.prisma2 migrate save --name 'init' --experimental
Creates a new migration based on changes on your data model. In this context, it automatically documents all changes (i.e., a git diff
). All changes are only applied locally and are not applied to the database. However, the migration is already written into the _Migration
table of your database (which stores your project's migration history).
Runs all migrations that have not been applied to the database yet. This command effectively "replays" all local changes to the database.
This command reverts a database migration. In turn, it creates a "compensation" migration that undoes previous changes.