Migrate prisma init --db to new connection model#29283
Migrate prisma init --db to new connection model#29283kristof-siket wants to merge 7 commits intomainfrom
prisma init --db to new connection model#29283Conversation
…onnection model Read the connection string from `connections[0].endpoints.direct.connectionString` instead of manually constructing a DSN from `database.directConnection` fields. Falls back to the legacy `directConnection` path when `connections` is absent or endpoints lack a `connectionString`, for backward compatibility with older API versions. Also bumps `@prisma/management-api-sdk` from 0.2.0 to 1.12.0, which includes the new connection model types and renames the SDK exports: - `ManagementAPI` -> `ManagementApiSdk` - `createManagementAPI` -> `createManagementApiSdk` Closes TML-1927
|
Note Reviews pausedIt looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the Use the following commands to manage reviews:
Use the checkboxes below for quick actions:
WalkthroughUpdate Changes
🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
The API doesn't guarantee ordering of connections[], so the first entry might be an accelerate connection without direct/pooled endpoints. Use .find() to locate a connection that has a connectionString available, and also try pooled endpoint before falling back to legacy directConnection.
size-limit report 📦
|
Use connectionString directly from the connections endpoint array. Drop the directConnection fallback — the API always returns the connections array with connectionString populated.
…ted-connection-fields-to
Merging this PR will not alter performance
Comparing Footnotes
|
Fixes IP spoofing authentication bypass vulnerability (GHSA-xxxxx).
The previous override (>=4.11.10) allowed 4.12.0-4.12.1 which are vulnerable to authentication bypass by IP spoofing (GHSA-xh87-mx6m-69f3). The transitive dependency @prisma/dev>hono resolved to a version in that range.
| "overrides": { | ||
| "form-data": ">=4.0.4", | ||
| "hono": ">=4.11.10", | ||
| "hono": ">=4.12.2", |
Summary
Migrates
prisma init --dbfrom reading deprecateddatabase.directConnectionfields to the newconnections[].endpoints.direct.connectionStringfrom the Management API response (TML-1927).connections[].endpoints.direct.connectionString— no manual DSN construction needed@prisma/management-api-sdkfrom0.2.0to1.12.0to get the new connection model typesManagementAPI->ManagementApiSdk,createManagementAPI->createManagementApiSdk)honofrom4.11.7to4.12.3to fix IP spoofing authentication bypass vulnerabilityContext
The Management API shipped a new connection model in PR #3365. The deprecated fields (
directConnection,apiKeys) will be removed after a deprecation window. This migration ensuresprisma init --dbworks with the new response shape.Related: PTL-1046 — same migration for
prisma/create-db(PR #80)Test plan
prisma init --dbcreates a project and returns a valid connection string (manual test against production API)Closes TML-1927
Summary by CodeRabbit
Bug Fixes
Chores