Skip to content

Add database management commands to Prisma CLI#76

Merged
luanvdw merged 3 commits into
mainfrom
feat/database-cli
Jun 9, 2026
Merged

Add database management commands to Prisma CLI#76
luanvdw merged 3 commits into
mainfrom
feat/database-cli

Conversation

@luanvdw

@luanvdw luanvdw commented Jun 9, 2026

Copy link
Copy Markdown
Member

Overview

Adds the first Prisma Postgres database management slice to the platform CLI: database CRUD plus nested connection-string lifecycle commands.

Changes

  • Documents database as the canonical beta command group, with no public db or postgres aliases.
  • Adds database list/show/create/remove and database connection list/create/remove command routing, controllers, presenters, types, fixtures, and Management API provider calls.
  • Prints one-time connection URLs only on create commands: raw URL on stdout in human mode, and result.connectionString exactly once in JSON mode.
  • Keeps list/show outputs metadata-only and strips secret values from normalized database and connection records.
  • Gates destructive database and connection removal behind exact id confirmation with --confirm <id>.

Why

database is the durable public noun for the platform command model, while connection is nested because connection strings only exist in the context of a database. The output contract keeps secrets easy for scripts to capture without implying an env-var name or repeating the value in human output.

Verification

  • pnpm --filter @prisma/cli test (clean pass: 39 files, 378 tests; first run hit a local Vitest worker EAGAIN spawn flake and passed on rerun)
  • pnpm --filter @prisma/cli build
  • git diff --check
  • skills/engineering/tmp-code-review/ and skills/engineering/thermonuclear-review/ against the branch diff

@coderabbitai

coderabbitai Bot commented Jun 9, 2026

Copy link
Copy Markdown

Review Change Stack

Warning

Review limit reached

@luanvdw, we couldn't start this review because you've reached your PR review rate limit.

More reviews will be available in 39 minutes and 1 second. Learn how PR review limits work.

Your organization has run out of usage credits. Purchase more in the billing tab.

⌛ How to resolve this issue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans include higher PR review limits than trial, open-source, and free plans. In all cases, reviews become available again over time. During sustained high-volume PR review activity, CodeRabbit may temporarily slow when the next review becomes available.

Please see our Fair Usage Limits Policy for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro

Run ID: f1b61b3c-b278-4340-adc0-cc6232e02855

📥 Commits

Reviewing files that changed from the base of the PR and between 0db8243 and d4c4e30.

📒 Files selected for processing (3)
  • docs/product/command-spec.md
  • packages/cli/src/controllers/database.ts
  • packages/cli/src/lib/database/provider.ts

Walkthrough

This PR implements a comprehensive database command group for the Prisma CLI, enabling users to discover and manage databases through commands like database list, database show, database create, and database remove. It adds support for nested database connection operations to manage one-time connection strings. The implementation spans specification documents, type contracts, a mock API adapter with fixture data, a Management API provider, command presenters for human and JSON output, command controller logic with fixture/real-mode switching, CLI command registration, and an extensive test suite covering all command paths and error scenarios.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title 'Add database management commands to Prisma CLI' clearly and directly summarizes the main change: introducing database CRUD and connection management commands to the CLI.
Description check ✅ Passed The description is directly related to the changeset, providing an overview of database CRUD and connection management features, explaining the rationale, and listing verification steps performed.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/database-cli
✨ Simplify code
  • Create PR with simplified code
  • Commit simplified code in branch feat/database-cli

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@luanvdw luanvdw self-assigned this Jun 9, 2026
# Conflicts:
#	docs/product/error-conventions.md
#	docs/product/resource-model.md
@luanvdw luanvdw marked this pull request as ready for review June 9, 2026 03:42

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@packages/cli/src/controllers/database.ts`:
- Around line 457-459: The timestamp-only defaultConnectionName() can collide if
two connections are created in the same millisecond; modify the function to
append a short random suffix (e.g., 4 hex chars) to the generated name to add
entropy. Locate defaultConnectionName(), generate a 4-character hex (or similar)
random string and concatenate it to the timestamp-based name (e.g.,
`cli-<timestamp>-<rand>`), ensuring the function still returns a string and
preserving the existing timestamp format.

In `@packages/cli/src/lib/database/provider.ts`:
- Line 144: The current showDatabase call normalizes the API result with
normalizeDatabase(..., "") which produces an empty-string projectId that only
gets corrected later by ensureProjectId; update showDatabase (and
provider.showDatabase signature) to accept an optional projectId/context and use
that when result.data.data.projectId is missing, or alternatively detect a
missing projectId in provider.showDatabase and surface an explicit error instead
of normalizing with an empty string; adjust the caller in
controllers/database.ts to pass target.project.id into showDatabase (or handle
the surfaced error) so normalizeDatabase is never called with an empty-string
fallback and DatabaseSummary always has a valid projectId.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro

Run ID: 3251f6b4-ec29-45e3-8db9-4ef5a6e85b0a

📥 Commits

Reviewing files that changed from the base of the PR and between ce51e25 and 0db8243.

📒 Files selected for processing (20)
  • docs/product/command-principles.md
  • docs/product/command-spec.md
  • docs/product/error-conventions.md
  • docs/product/output-conventions.md
  • docs/product/resource-model.md
  • packages/cli/fixtures/mock-api.json
  • packages/cli/src/adapters/mock-api.ts
  • packages/cli/src/cli.ts
  • packages/cli/src/commands/database/index.ts
  • packages/cli/src/controllers/database.ts
  • packages/cli/src/lib/database/provider.ts
  • packages/cli/src/presenters/database.ts
  • packages/cli/src/shell/command-meta.ts
  • packages/cli/src/shell/command-runner.ts
  • packages/cli/src/shell/errors.ts
  • packages/cli/src/types/database.ts
  • packages/cli/tests/app-build.test.ts
  • packages/cli/tests/database.test.ts
  • packages/cli/tests/shell.test.ts
  • packages/cli/tests/version.test.ts

Comment thread packages/cli/src/controllers/database.ts
Comment thread packages/cli/src/lib/database/provider.ts Outdated
@luanvdw luanvdw requested a review from AmanVarshney01 June 9, 2026 06:05
@luanvdw luanvdw merged commit 0ba844c into main Jun 9, 2026
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant