Add database management commands to Prisma CLI#76
Conversation
|
Warning Review limit reached
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 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 configurationConfiguration used: Organization UI Review profile: ASSERTIVE Plan: Pro Run ID: 📒 Files selected for processing (3)
WalkthroughThis PR implements a comprehensive 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
✨ Simplify code
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. Comment |
# Conflicts: # docs/product/error-conventions.md # docs/product/resource-model.md
There was a problem hiding this comment.
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
📒 Files selected for processing (20)
docs/product/command-principles.mddocs/product/command-spec.mddocs/product/error-conventions.mddocs/product/output-conventions.mddocs/product/resource-model.mdpackages/cli/fixtures/mock-api.jsonpackages/cli/src/adapters/mock-api.tspackages/cli/src/cli.tspackages/cli/src/commands/database/index.tspackages/cli/src/controllers/database.tspackages/cli/src/lib/database/provider.tspackages/cli/src/presenters/database.tspackages/cli/src/shell/command-meta.tspackages/cli/src/shell/command-runner.tspackages/cli/src/shell/errors.tspackages/cli/src/types/database.tspackages/cli/tests/app-build.test.tspackages/cli/tests/database.test.tspackages/cli/tests/shell.test.tspackages/cli/tests/version.test.ts
Overview
Adds the first Prisma Postgres database management slice to the platform CLI: database CRUD plus nested connection-string lifecycle commands.
Changes
databaseas the canonical beta command group, with no publicdborpostgresaliases.database list/show/create/removeanddatabase connection list/create/removecommand routing, controllers, presenters, types, fixtures, and Management API provider calls.result.connectionStringexactly once in JSON mode.--confirm <id>.Why
databaseis the durable public noun for the platform command model, whileconnectionis 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 workerEAGAINspawn flake and passed on rerun)pnpm --filter @prisma/cli buildgit diff --checkskills/engineering/tmp-code-review/andskills/engineering/thermonuclear-review/against the branch diff