Skip to content

Conversation

@aidankmcalister
Copy link
Member

@aidankmcalister aidankmcalister commented Jan 9, 2026

Summary by CodeRabbit

Documentation

  • Expanded Prisma Studio embedding documentation to support PostgreSQL, SQLite, and MySQL with database-specific setup instructions, code examples, and endpoints.
  • Updated Next.js integration guide with per-database configurations, adapter implementations, API endpoints, and production-ready setup considerations for each supported database type.

✏️ Tip: You can customize this high-level summary in your review settings.

@github-actions
Copy link
Contributor

github-actions bot commented Jan 9, 2026

Dangerous URL check

No absolute URLs to prisma.io/docs found.
No local URLs found.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Jan 9, 2026

Walkthrough

The docs were expanded from PostgreSQL-only to multi-database embedding: Prisma Studio embedding and Next.js guide now support PostgreSQL, SQLite, and MySQL, replacing Postgres-specific wording with database-agnostic terminology and adding per-database examples and setup steps.

Changes

Cohort / File(s) Summary
Embedded Studio core doc
content/250-postgres/300-database/675-prisma-studio/100-embedding-studio.mdx
Converted Postgres-specific guidance to database-agnostic content; added "Database support" section (Postgres, SQLite, MySQL); updated backend/frontend examples, adapters, installation commands, and custom headers/payload examples for each DB.
Next.js embed Studio guide
content/800-guides/360-embed-studio-nextjs.mdx
Reworked guide into tabbed per-database flow (Postgres, SQLite, MySQL): per-DB install, Prisma init/datasource, seeding, API endpoints, adapter/executor setup, and frontend Studio wrapper examples; added next steps and verification notes.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~15 minutes

Possibly related PRs

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title directly reflects the main change: expanding embedded studio documentation to support SQLite and MySQL alongside PostgreSQL.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

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


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

@github-actions
Copy link
Contributor

github-actions bot commented Jan 9, 2026

Redirect check

This PR probably requires the following redirects to be added to static/_redirects:

  • This PR does not change any pages in a way that would require a redirect.

@cloudflare-workers-and-pages
Copy link

cloudflare-workers-and-pages bot commented Jan 9, 2026

Deploying docs with  Cloudflare Pages  Cloudflare Pages

Latest commit: acb9dc2
Status: ✅  Deploy successful!
Preview URL: https://f2f5907a.docs-51g.pages.dev
Branch Preview URL: https://feat-dr-6472-sqlite-mysql-em.docs-51g.pages.dev

View logs

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 5

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (7)
content/250-postgres/300-database/675-prisma-studio/100-embedding-studio.mdx (5)

23-25: Fix grammar: “a quick admin dashboard”.

Line 23: “Create an quick…” → “Create a quick…”.


80-165: All three frontend snippets use useMemo but don’t import it (copy/paste break).

Each TSX example calls useMemo(...) but never imports it from React. Consider adding import { useMemo } from "react"; (or import React, { useMemo } ...) to each snippet to make them runnable.

Proposed fix (apply similarly to SQLite/MySQL snippets)
 import { Studio } from "@prisma/studio-core/ui";
 import { createPostgresAdapter } from "@prisma/studio-core/data/postgres-core";
 import { createStudioBFFClient } from "@prisma/studio-core/data/bff";
+import { useMemo } from "react";
 import "@prisma/studio-core/ui/index.css"

404-430: Avoid logging headers/payload in auth examples (risk of leaking secrets/PII).

Lines 410-413 console.log request-derived values; readers often copy/paste this into prod. Consider removing logs or explicitly warning to never log auth tokens / sensitive identifiers.


279-305: Add validation for DATABASE_URL in the PostgreSQL backend implementation to match SQLite and MySQL patterns.

The PostgreSQL section omits the DATABASE_URL validation that both the SQLite and MySQL sections include. This creates an inconsistency where undefined gets silently passed to createPrismaPostgresHttpClient, leading to a less obvious error message. Adding the validation ensures consistent, clear error handling across all database backends.

Proposed fix
  // 2. Read DB URL from env vars
  const url = process.env.DATABASE_URL;
  
+  if (!url) {
+    return c.json([serializeError(new Error("DATABASE_URL is missing"))], 500);
+  }
+
  // 3. Execute the query against Prisma Postgres
  const [error, results] = await createPrismaPostgresHttpClient({ url }).execute(query);

170-193: Add missing imports for SQLite and MySQL adapters so switching database types actually works.

The snippet advertises support for all database types but only imports the PostgreSQL adapter. Lines 191–192 show createSQLiteAdapter and createMySQLAdapter commented out, but if a developer uncomments either line, they'll get a ReferenceError because those functions aren't imported.

Since the section claims to "work for all database types," either add the missing imports at the top or rewrite the snippet to clarify that developers must replace the Postgres import and call with the database adapter of their choice.

Proposed fix
 import { Studio } from "@prisma/studio-core/ui";
 import { createPostgresAdapter } from "@prisma/studio-core/data/postgres-core";
+import { createSQLiteAdapter } from "@prisma/studio-core/data/sqlite-core";
+import { createMySQLAdapter } from "@prisma/studio-core/data/mysql-core";
 import { createStudioBFFClient } from "@prisma/studio-core/data/bff";
 import "@prisma/studio-core/ui/index.css"
content/800-guides/360-embed-studio-nextjs.mdx (2)

571-576: CORS header example is dangerously permissive for a “production-ready” guide.

Access-Control-Allow-Origin: "*" (Line 572) is fine for a toy demo, but this endpoint executes arbitrary queries. Consider adding a bold warning + show a locked-down example origin (or recommend same-origin only, since it’s /api/studio in the same Next app).


159-168: Schema snippet is incomplete and misleading: missing required url field and lacks database variants.

The datasource block at lines 165–167 omits the required url field and only shows provider = "postgresql". While the init command earlier (section 2.2) demonstrates multi-database options via --datasource-provider, the schema snippet doesn't reflect this. According to Prisma configuration requirements, the datasource block must include url.

Although prisma.config.ts later provides the URL via datasource: { url: env("DATABASE_URL") }, the schema.prisma snippet should be self-contained. Update the snippet to either:

  • Include url = env("DATABASE_URL") in the datasource block, and/or
  • Show tabbed variants for PostgreSQL, SQLite, and MySQL to match the init command options presented earlier.
🤖 Fix all issues with AI agents
In
@content/250-postgres/300-database/675-prisma-studio/100-embedding-studio.mdx:
- Around line 13-14: Change the misleading comment that reads "Execute the query
against Prisma Postgres" to "Execute the query against PostgreSQL" so it doesn't
imply exclusivity; update the comment located near the implementation or usage
of createPrismaPostgresHttpClient (and any similar doc string referencing Prisma
Postgres) to reflect that the executor works with any PostgreSQL instance, not
only Prisma-managed Postgres.
- Around line 54-67: The sentence claiming "PostgreSQL support is included with
`@prisma/studio-core` and requires no additional dependencies" should be
softened and clarified: change it to indicate that `@prisma/studio-core` bundles
PostgreSQL support at the library level but that running Studio in a backend
still requires a working Postgres connection and typical backend tooling (for
example using `Prisma Client`) will still need the `pg` driver or other
infrastructure-level dependencies; mention `@prisma/studio-core`, `Prisma
Client`, and `pg` to guide readers.
- Around line 311-348: The handler currently strips the file URI with
url.replace("file:", "") and creates a new better-sqlite3 Database per request;
change this by using an anchored regex to remove only a leading "file:" (e.g.,
dbPath = DATABASE_URL.replace(/^file:/, "")) and move DatabaseSync instantiation
out of app.post("/studio") so a single DatabaseSync instance is created once (at
module scope) and reused; update references to dbPath/DATABASE_URL and keep
createNodeSQLiteExecutor(database).execute(query) inside the handler, and add a
brief comment documenting the expected DATABASE_URL format (e.g.,
"file:./dev.db").

In @content/800-guides/360-embed-studio-nextjs.mdx:
- Around line 145-154: The heading "### 2.2. What the init command creates" is
duplicated; rename that heading to "### 2.3. What the init command creates" and
increment the numbering of subsequent section headings accordingly to restore
sequential numbering and stable anchors; locate the heading by the exact text
"What the init command creates" and update any following "2.2" occurrences in
this file to the next numbers (e.g., 2.3 → 2.4, etc.) so all section numbers
remain consistent.
- Around line 84-113: The MySQL TabItem contains an incorrect dev dependency
"@types/mysql2" which doesn't exist and breaks installs; edit the TabItem with
value="mysql" (the MySQL install block) to remove "@types/mysql2" from the dev
install command so it reads only "npm install prisma tsx --save-dev" while
keeping the runtime installs (e.g., @prisma/client @prisma/adapter-mysql dotenv
mysql2) unchanged.
🧹 Nitpick comments (3)
content/250-postgres/300-database/675-prisma-studio/100-embedding-studio.mdx (1)

354-390: MySQL pool created per request (connection churn) — prefer a single shared pool.

Line 375 creates a new pool for every request; that’s both slow and can exhaust connections. Even in docs, a “minimal but safe” pattern would define const pool = mysql.createPool(url) once (or cache by tenant) and reuse it.

content/800-guides/360-embed-studio-nextjs.mdx (2)

426-485: Good: datasource url differs by DB — but call out the env var expectation earlier.

Postgres uses env('DIRECT_URL') (Line 440) while SQLite/MySQL use env('DATABASE_URL') (Lines 459, 478). That’s correct for many Prisma Postgres setups, but earlier sections emphasize only DATABASE_URL; consider a short note that Prisma Postgres commonly needs both DATABASE_URL and DIRECT_URL (what each is used for).


566-632: Next.js route handler examples: avoid dotenv/config, and don’t create DB/pool per request.

  • In Next.js, .env is loaded by the framework; import "dotenv/config" inside route.ts is usually unnecessary and sometimes confusing.
  • SQLite/MySQL examples create a DB handle / pool on every request; that’s costly and can exhaust connections. Prefer module-level singletons (or cached per tenant) in the example.

Also applies to: 638-706, 711-777

📜 Review details

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 500e472 and fbde34a.

📒 Files selected for processing (2)
  • content/250-postgres/300-database/675-prisma-studio/100-embedding-studio.mdx
  • content/800-guides/360-embed-studio-nextjs.mdx
🧰 Additional context used
🧠 Learnings (1)
📚 Learning: 2026-01-06T22:06:57.725Z
Learnt from: newclarityex
Repo: prisma/docs PR: 7425
File: content/200-orm/050-overview/500-databases/400-mysql.mdx:80-80
Timestamp: 2026-01-06T22:06:57.725Z
Learning: In Prisma docs, when showing examples of instantiating driver adapters with connection strings from environment variables, use the template literal pattern `const connectionString = `${process.env.DATABASE_URL}`` for consistency across all database adapter examples (PostgreSQL, MySQL/MariaDB, etc.).

Applied to files:

  • content/250-postgres/300-database/675-prisma-studio/100-embedding-studio.mdx
  • content/800-guides/360-embed-studio-nextjs.mdx
🪛 LanguageTool
content/800-guides/360-embed-studio-nextjs.mdx

[style] ~560-~560: Consider a more expressive alternative.
Context: ...s (or errors) back to the frontend. To do this, create a new folder called api ...

(DO_ACHIEVE)

⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (2)
  • GitHub Check: Check internal links
  • GitHub Check: Cloudflare Pages
🔇 Additional comments (1)
content/800-guides/360-embed-studio-nextjs.mdx (1)

232-418: Align seed script environment variables with guide context; Postgres tab doesn't require DIRECT_URL in adapter instantiation.

The seed script's use of process.env.DATABASE_URL! is correct for runtime adapter code. The @prisma/adapter-pg adapter instantiation receives a connectionString parameter directly—it doesn't read from schema.prisma or prisma.config.ts. The DIRECT_URL in the prisma.config.ts datasource (line 440) is for Prisma CLI operations like migrations, not for runtime seed scripts.

However, there's a real inconsistency in the guide: the Postgres prisma.config.ts specifies env('DIRECT_URL') while the seed script and SQLite/MySQL examples use env('DATABASE_URL'). For clarity and consistency, either:

  1. Simplify: Use env('DATABASE_URL') across all three tabs in prisma.config.ts (matches what prisma init creates and what seeds use), or
  2. Document: Explain why Postgres uses DIRECT_URL in the config and clarify that users should set both DATABASE_URL (for runtime) and DIRECT_URL (for CLI) in their .env.

The stylistic suggestion to use const connectionString = \${process.env.DATABASE_URL}`for consistency across all three seed tabs is reasonable, but the core fix is addressing theDIRECT_URL` inconsistency at the guide level, not in the seeds.

Likely an incorrect or invalid review comment.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 2

🤖 Fix all issues with AI agents
In @content/800-guides/360-embed-studio-nextjs.mdx:
- Around line 754-756: The code creates a new MySQL pool on every request by
calling mysql.createPool(...) inside the request handler; move the pool creation
out of the per-request flow so a single shared pool is reused across requests
(e.g., create a module-level or singleton pool variable and initialize it once),
then pass that reusable pool into createMySQL2Executor(pool).execute(query)
instead of recreating mysql.createPool for each POST.
- Around line 84-113: The package names for the SQLite and MySQL Prisma adapters
in the TabItem blocks are incorrect; update the SQLite install line to use the
actual adapter package name @prisma/adapter-better-sqlite3 (replace
@prisma/adapter-sqlite) and update the MySQL install line to use
@prisma/adapter-mariadb (replace @prisma/adapter-mysql) so the TabItem blocks
labeled "SQLite" and "MySQL" list the correct npm packages to install.
🧹 Nitpick comments (3)
content/800-guides/360-embed-studio-nextjs.mdx (3)

166-166: Clarify the datasource provider for multi-database examples.

The comment states the provider "will change depending on the --datasource-provider flag," but the value shown is "postgresql". For a multi-database guide, consider using a placeholder comment or showing all three options to reduce confusion.

📝 Suggested clarification
 datasource db {
-  provider = "postgresql" // this will change depending on the --datasource-provider flag used in the init command
+  provider = "postgresql" // or "sqlite" or "mysql" depending on the --datasource-provider flag used in the init command
 }

682-683: Strengthen SQLite file path extraction.

The simple string replacement url.replace("file:", "") may fail with variations like file://, relative paths, or query parameters. Consider using a more robust URL parsing approach.

🔧 Proposed improvement using URL parsing
     // Execute query using SQLite
-    const dbPath = url.replace("file:", "");
+    const dbPath = url.startsWith("file:") 
+      ? new URL(url).pathname 
+      : url;
     const database = new DatabaseSync(dbPath);
     const [error, results] = await createNodeSQLiteExecutor(database).execute(query);

236-237: Consider template literal pattern for consistency.

Based on learnings, Prisma docs prefer the template literal pattern for connection strings: const connectionString = `${process.env.DATABASE_URL}`. While the current direct reference works, using the template literal would provide better consistency across documentation examples.

Additionally, the non-null assertion (!) assumes DATABASE_URL is always defined. Consider adding a runtime check for better error handling.

♻️ Suggested pattern for consistency

For PostgreSQL adapter (similar for SQLite and MySQL):

+const connectionString = `${process.env.DATABASE_URL}`
+
+if (!connectionString) {
+  throw new Error('DATABASE_URL environment variable is required')
+}
+
 const adapter = new PrismaPg({
-  connectionString: process.env.DATABASE_URL!,
+  connectionString,
 })

Based on learnings, the template literal pattern provides consistency across all database adapter examples.

Also applies to: 300-301, 364-365

📜 Review details

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between fbde34a and acb9dc2.

📒 Files selected for processing (1)
  • content/800-guides/360-embed-studio-nextjs.mdx
🧰 Additional context used
🧠 Learnings (1)
📚 Learning: 2026-01-06T22:06:57.725Z
Learnt from: newclarityex
Repo: prisma/docs PR: 7425
File: content/200-orm/050-overview/500-databases/400-mysql.mdx:80-80
Timestamp: 2026-01-06T22:06:57.725Z
Learning: In Prisma docs, when showing examples of instantiating driver adapters with connection strings from environment variables, use the template literal pattern `const connectionString = `${process.env.DATABASE_URL}`` for consistency across all database adapter examples (PostgreSQL, MySQL/MariaDB, etc.).

Applied to files:

  • content/800-guides/360-embed-studio-nextjs.mdx
🪛 LanguageTool
content/800-guides/360-embed-studio-nextjs.mdx

[style] ~560-~560: Consider a more expressive alternative.
Context: ...s (or errors) back to the frontend. To do this, create a new folder called api ...

(DO_ACHIEVE)

⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
  • GitHub Check: Cloudflare Pages
🔇 Additional comments (3)
content/800-guides/360-embed-studio-nextjs.mdx (3)

428-485: This is correct and intentional documentation.

The DIRECT_URL for Prisma Postgres is specifically for use with connection pooling. Prisma separates concerns: DIRECT_URL is used by Prisma CLI commands (migrations, introspection) which need direct database access, while DATABASE_URL is used by the application at runtime. This pattern is documented throughout the Prisma guides (Supabase, Neon, PgBouncer, etc.). SQLite doesn't use connection pooling, so DATABASE_URL is appropriate for direct connections. There are no seed files in this documentation repository to verify the secondary claim about seed file references.


827-827: Adapter function names are correct.

The code correctly uses createPostgresAdapter, createSQLiteAdapter, and createMySQLAdapter from their respective @prisma/studio-core/data/* modules (postgres-core, sqlite-core, mysql-core). These functions are documented and follow Prisma Studio Core's standard adapter factory pattern.


609-611: All executor function names are correct and already in use.

Verification confirms that all three executor functions from @prisma/studio-core are correctly named and properly utilized in the code:

  • createPrismaPostgresHttpClient (line 609) ✓
  • createNodeSQLiteExecutor (line 684) ✓
  • createMySQL2Executor (line 756) ✓

Each follows the expected pattern of instantiation with database-specific configuration followed by .execute(query). No corrections needed.

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.

2 participants