Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
66 changes: 62 additions & 4 deletions content/200-orm/500-reference/200-prisma-cli-reference.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -879,6 +879,52 @@ Fetching latest updates for this subcommand...

</CodeWithResult>

**Run `prisma dev` with a specific name**

```terminal
npx prisma dev --name="mydbname"
```

This creates a named instance called `mydbname` that you can later start, stop, or manage using the instance management commands.

### `dev start`

Starts existing [local Prisma Postgres](/postgres/database/local-development) instances in the background.

:::note

This command only works with instances that already exist.

:::

```terminal
npx prisma dev start <glob>
```

`<glob>` is a placeholder for a glob pattern to specify which local Prisma Postgres instances should be started, for example:

```terminal
npx prisma dev start mydb # starts a DB called `mydb` in the background (only if it already exists)
```

To start all databases that begin with `mydb` (e.g. `mydb-dev` and `mydb-prod`), you can use a glob:

```terminal
npx prisma dev start mydb* # starts all existing DBs starting with `mydb`
```

This enables background instance management outside of the VS Code extension.

### `dev ls`

Lists all available [local Prisma Postgres](/postgres/database/local-development) instances:

```terminal
npx prisma dev ls
```

This command shows all instances on your system with their current status and configuration.

### `dev stop`

Stops one or more [local Prisma Postgres](/postgres/database/local-development) databases:
Expand All @@ -899,6 +945,12 @@ To stop all databases that begin with `mydb` (e.g. `mydb-dev` and `mydb-prod`),
npx prisma dev stop mydb* # stops all DBs starting with `mydb`
```

:::note

The `stop` command is interactive and includes safety prompts to prevent accidental operations.

:::

### `dev rm`

Removes the data of one or more [local Prisma Postgres](/postgres/database/local-development) databases from your file system:
Expand All @@ -910,14 +962,20 @@ npx prisma dev rm <glob>
`<glob>` is a placeholder for a glob pattern to specify which local Prisma Postgres instances should be removed, for example:

```terminal
npx prisma dev stop mydb # stops a DB called `mydb`
npx prisma dev rm mydb # removes a DB called `mydb`
```

To stop all databases that begin with `mydb` (e.g. `mydb-dev` and `mydb-prod`), you can use a glob:
To remove all databases that begin with `mydb` (e.g. `mydb-dev` and `mydb-prod`), you can use a glob:

```terminal
npx prisma dev rm mydb* # removes all DBs starting with `mydb`
```
npx prisma dev stop mydb* # stops all DBs starting with `mydb`
```

:::note

The `rm` command is interactive and includes safety prompts to prevent accidental data loss.

:::


## `db`
Expand Down
54 changes: 52 additions & 2 deletions content/250-postgres/300-database/550-local-development.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -83,10 +83,48 @@ To transition to production, you only need to update the database URL in the `.e
You can target a specific, local Prisma Postgres instance via the `--name` (`-n`) option of the `prisma dev` command, for example:

```terminal
npx prisma dev --name mydb1
npx prisma dev --name="mydb1"
```

Whenever you pass the `--name mydb1` to `prisma dev`, the command will return the same connection string pointing to a local instance called `mydb1`.
Whenever you pass the `--name="mydb1"` to `prisma dev`, the command will return the same connection string pointing to a local instance called `mydb1`. This creates a named instance that you can later manage using the instance management commands.

## Starting existing Prisma Postgres instances in the background

You can start existing Prisma Postgres instances in the background using:

```terminal
npx prisma dev start <glob>
```

:::note

The `dev start` command only works with instances that already exist.

:::

`<glob>` is a placeholder for a glob pattern to specify which local Prisma Postgres instances should be started, for example:

```terminal
npx prisma dev start mydb # starts a DB called `mydb` in the background (only if it already exists)
```

To start all databases that begin with `mydb` (e.g. `mydb-dev` and `mydb-prod`), you can use a glob:

```terminal
npx prisma dev start mydb* # starts all existing DBs starting with `mydb`
```

This command enables you to manage Prisma Postgres instances outside of the VS Code extension, allowing for background instance management in your development workflow.

## Listing Prisma Postgres instances

You can view all your local Prisma Postgres instances using:

```terminal
npx prisma dev ls
```

This command lists all available instances on your system, showing their current status and configuration.

## Stopping Prisma Postgres instances

Expand All @@ -108,6 +146,12 @@ To stop all databases that begin with `mydb` (e.g. `mydb-dev` and `mydb-prod`),
npx prisma dev stop mydb* # stops all DBs starting with `mydb`
```

:::note

The `stop` command is interactive and includes safety prompts to prevent accidental operations. You'll be asked to confirm the action by typing a confirmation phrase.

:::

## Removing Prisma Postgres instances

Prisma Postgres saves the information and data from your local Prisma Postgres instances on your file system. To remove any trace from a database that's not in use any more, you can run the following command:
Expand All @@ -128,6 +172,12 @@ To stop all databases that begin with `mydb` (e.g. `mydb-dev` and `mydb-prod`),
npx prisma dev rm mydb* # removes all DBs starting with `mydb`
```

:::note

The `rm` command is interactive and includes safety prompts to prevent accidental data loss. You'll be asked to confirm the action by typing a confirmation phrase that hints at the risks involved.

:::

## Using local Prisma Postgres with any ORM

Local Prisma Postgres supports [direct TCP connections](/postgres/database/direct-connections), allowing you to connect to it via any tool.
Expand Down
1 change: 1 addition & 0 deletions static/_redirects
Original file line number Diff line number Diff line change
Expand Up @@ -839,6 +839,7 @@
/reference/errors/migrate-resolve /docs/orm/prisma-migrate/workflows/patching-and-hotfixing#failed-migration
/reference/errors/migrate-shadow /docs/orm/prisma-migrate/understanding-prisma-migrate/shadow-database

/data-platform/accelerate/concepts* /docs/accelerate

### NO REDIRECTS BELOW THIS LINE. ADD REDIRECTS ABOVE THIS SECTION ###

Loading