docs: add MongoDB migration guide from v6 to Prisma Next - #8111
Conversation
|
@RaschidJFR is attempting to deploy a commit to the Prisma Team on Vercel. A member of the Team first needs to authorize it. |
WalkthroughAdds a published “Upgrade Prisma ORM” guide for migrating Prisma v6 MongoDB projects to Prisma Next, covering setup, contracts, client APIs, migration commands, production cutover, and ongoing workflows. ChangesMongoDB migration documentation
Estimated code review effort: 3 (Moderate) | ~25 minutes 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
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 |
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 `@apps/docs/content/docs/guides/next/upgrade-prisma-orm/mongodb.mdx`:
- Around line 388-401: Update the pre-flight checklist in the migration guide to
restore the two missing safety checks: verify the configuration uses the same
database and connection string as v6, and verify MongoDB is version 8.0 or
newer. Keep the existing checklist items and wording unchanged otherwise.
- Around line 334-364: Update the raw-command documentation around the
“Commands” section and Quick reference table to document the existing
db.query.rawCommand(...) API for supported whole-command operations. Replace the
inaccurate mongo({ mongoClient, dbName, contractJson }) reference, while keeping
arbitrary generic commands described separately through the standalone
MongoClient example; ensure the surrounding prose and table consistently match
these examples.
🪄 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: Repository UI
Review profile: CHILL
Plan: Pro Plus
Run ID: bcee30fb-3643-44bc-a44c-199dd8d2ee41
📒 Files selected for processing (4)
MIGRATION.mdapps/docs/content/docs/guides/next/meta.jsonapps/docs/content/docs/guides/next/upgrade-prisma-orm/meta.jsonapps/docs/content/docs/guides/next/upgrade-prisma-orm/mongodb.mdx
…d filters, and raw-command mapping Every command and snippet now runs against a live v6 database on mongodb-memory-server (mongod 8.0.4 replica set) migrated to @prisma-next/mongo@0.16.0. Changes that came out of that run: - Step 4: db init refuses a populated v6 database (validator adds are classed destructive), and migration plans start from an empty baseline without a ref, so the adoption path is db update --advance-ref db, with plan/migrate/verify for every change after that. - 3c: the typed pipeline builder passes ObjectId values through as strings, so match on an ObjectId field silently returns nothing; grouped example no longer filters by authorId and a warning shows the working rawCommand + ObjectId pattern. - 3e/quick reference: $runCommandRaw maps to sharing one MongoClient with the mongo() binding (mongoClient + dbName), shown end to end; collection-scoped escapes point at db.query.rawCommand. - Checklist: restore same-database and MongoDB 8.0+ items; rehearsal commands now match the adoption flow. - Step 2: note that every discriminator value in existing data needs a declared variant with at least one field. - Align snippets with the actual init scaffold (contract.d import, non-null env assertions), storage-value enum row in common mistakes, relative docs links, em-dash cleanup. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
|
Validated this guide end to end against @prisma-next/mongo@0.16.0: a Prisma v6 app (CRUD, groupBy, findRaw/aggregateRaw, $runCommandRaw, $transaction) running on a mongodb-memory-server 8.0.4 replica set, then migrated following the guide literally. Everything in sections 1-3 held up as written except two things, both fixed in 50e24b1 along with the CodeRabbit feedback:
Also aligned the snippets with what 🤖 Generated with Claude Code |
There was a problem hiding this comment.
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
apps/docs/content/docs/guides/next/upgrade-prisma-orm/mongodb.mdx (1)
299-319: 🩺 Stability & Availability | 🟠 Major | ⚡ Quick winClose caller-owned
MongoClientinstances explicitly.A binding constructed with
mongoClientdoes not close the client whendb.close()is called; the caller owns that pool. The transaction example also creates a local driver client without closing it after the session.
apps/docs/content/docs/guides/next/upgrade-prisma-orm/mongodb.mdx#L299-L319: closeclientafterawait session.endSession().apps/docs/content/docs/guides/next/upgrade-prisma-orm/mongodb.mdx#L365-L366: document closingmongoClientduring application shutdown or script teardown.apps/docs/content/docs/guides/next/upgrade-prisma-orm/mongodb.mdx#L393-L393: distinguish URL-owneddb.close()from externally ownedmongoClient.close().Proposed fix
} finally { await session.endSession(); + await client.close(); }-| `$connect` / `$disconnect` | lazy connect on first use; `db.close()` to disconnect | +| `$connect` / `$disconnect` | lazy connect on first use; use `db.close()` for a URL-bound client, or `mongoClient.close()` when supplying `mongoClient` |🤖 Prompt for 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. In `@apps/docs/content/docs/guides/next/upgrade-prisma-orm/mongodb.mdx` around lines 299 - 319, Update the MongoDB documentation at apps/docs/content/docs/guides/next/upgrade-prisma-orm/mongodb.mdx lines 299-319 to close the locally created client after session.endSession() in the transaction example. At lines 365-366, document that externally supplied mongoClient instances must be closed during application shutdown or script teardown. At line 393, distinguish URL-owned db.close() cleanup from explicitly calling mongoClient.close() for externally owned clients.
🤖 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.
Outside diff comments:
In `@apps/docs/content/docs/guides/next/upgrade-prisma-orm/mongodb.mdx`:
- Around line 299-319: Update the MongoDB documentation at
apps/docs/content/docs/guides/next/upgrade-prisma-orm/mongodb.mdx lines 299-319
to close the locally created client after session.endSession() in the
transaction example. At lines 365-366, document that externally supplied
mongoClient instances must be closed during application shutdown or script
teardown. At line 393, distinguish URL-owned db.close() cleanup from explicitly
calling mongoClient.close() for externally owned clients.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro Plus
Run ID: 2dadefb1-fe3d-4a2b-9b60-b3cb6d8823c8
📒 Files selected for processing (1)
apps/docs/content/docs/guides/next/upgrade-prisma-orm/mongodb.mdx
|
@coderabbitai resolve |
✅ Action performedComments resolved and changes approved. |
* docs: fix spellcheck failures from the MongoDB migration guide Add cutover to the cspell project dictionary and switch façade to facade in the guide. Follow-up to #8111, which landed with these two words failing the Spellcheck workflow on main. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> * docs: tell readers to align dbName with the v6 database Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> --------- Co-authored-by: Claude Fable 5 <noreply@anthropic.com>
Added
mongodb.mdxunder/docs/guides/next/upgrade-prisma-orm/mongodbSummary by CodeRabbit