diff --git a/content/200-orm/500-reference/200-prisma-cli-reference.mdx b/content/200-orm/500-reference/200-prisma-cli-reference.mdx index 0214184dd7..26b0217daa 100644 --- a/content/200-orm/500-reference/200-prisma-cli-reference.mdx +++ b/content/200-orm/500-reference/200-prisma-cli-reference.mdx @@ -839,13 +839,14 @@ The `dev` command starts a [local Prisma Postgres](/postgres/database/local-deve ### Arguments -| Argument | Required | Description | Default | -| --------------------- | -------- | --------------------------------------------------------------------------------------------------------------------------------------------------- | ------- | -| `--name` (or `-n`) | No | Enables targeting a specific database instance. [Learn more](/postgres/database/local-development#using-different-local-prisma-postgres-instances). | | -| `--port` (or `-p`) | No | Main port number the local Prisma Postgres HTTP server will listen on. | `51213` | -| `--db-port` (or `-P`) | No | Port number the local Prisma Postgres database server will listen on. | `51214` | -| `--shadow-db-port` | No | Port number the shadow database server will listen on. | `51215` | -| `--debug` | No | Enable debug logging. | `false` | +| Argument | Required | Description | Default | +| --------------------- | -------- | --------------------------------------------------------------------------------------------------------------------------------------------------- | --------- | +| `--name` (or `-n`) | No | Enables targeting a specific database instance. [Learn more](/postgres/database/local-development#using-different-local-prisma-postgres-instances). | `default` | +| `--port` (or `-p`) | No | Main port number the local Prisma Postgres HTTP server will listen on. | `51213` | +| `--db-port` (or `-P`) | No | Port number the local Prisma Postgres database server will listen on. | `51214` | +| `--shadow-db-port` | No | Port number the shadow database server will listen on. | `51215` | +| `--detach` (or `-d`) | No | Run the server in the background. | `false` | +| `--debug` | No | Enable debug logging. | `false` | ### Examples @@ -887,6 +888,14 @@ 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. +**Run `prisma dev` in detached mode** + +```terminal +npx prisma dev --detach +``` + +This runs the server in the background, freeing up your terminal for other commands. Use `prisma dev ls` to see running servers and `prisma dev stop` to stop them. + ### `dev start` Starts existing [local Prisma Postgres](/postgres/database/local-development) instances in the background. @@ -971,6 +980,12 @@ To remove all databases that begin with `mydb` (e.g. `mydb-dev` and `mydb-prod`) npx prisma dev rm mydb* # removes all DBs starting with `mydb` ``` +#### Arguments + +| Argument | Required | Description | Default | +| --------- | -------- | -------------------------------------------------------------------------------------------------------------------- | ------- | +| `--force` | No | Stops any running servers before removing them. Without this flag, the command will fail if any server is running. | `false` | + :::note The `rm` command is interactive and includes safety prompts to prevent accidental data loss. diff --git a/content/250-postgres/300-database/550-local-development.mdx b/content/250-postgres/300-database/550-local-development.mdx index 059443c287..fc0e3fdf61 100644 --- a/content/250-postgres/300-database/550-local-development.mdx +++ b/content/250-postgres/300-database/550-local-development.mdx @@ -50,7 +50,15 @@ If you want to connect via Prisma ORM, hit h on your keyboard, copy t DATABASE_URL="prisma+postgres://localhost:51213/?api_key=__API_KEY__" ``` -Keep the local Prisma Postgres server running in the background while you work on your application. +Keep the local Prisma Postgres server running in the background while you work on your application. + +Alternatively, you can run the server in detached mode to free up your terminal: + +```terminal +npx prisma dev --detach +``` + +This starts the server in the background. Use `prisma dev ls` to see running servers and `prisma dev stop` to stop them. ### 2. Applying migrations and seeding data @@ -166,12 +174,20 @@ npx prisma dev rm 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` ``` +You can use the `--force` flag to stop any running servers before removing them: + +```terminal +npx prisma dev rm mydb --force +``` + +Without `--force`, the command will fail if any server is still running. + :::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.