Skip to content

Conversation

AmanVarshney01
Copy link
Owner

@AmanVarshney01 AmanVarshney01 commented Sep 3, 2025

Summary by CodeRabbit

  • New Features

    • Prisma schema templates now include conditional runtime configuration (Bun, Node.js, Workers) and provide templated client generation and datasource setup for MongoDB, MySQL, SQLite, and Postgres via environment variables.
  • Chores

    • Bumped Prisma-related dependencies to ^6.15.0.
    • Bumped ORPC-related dependencies to ^1.8.6.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Sep 3, 2025

Caution

Review failed

The pull request is closed.

Walkthrough

Replaces static Prisma schema files with Handlebars templates that emit generator and datasource blocks (including conditional runtime lines for bun/node/workers), removes legacy static schema contents, and bumps dependencyVersionMap entries for Prisma and ORPC packages in the CLI constants.

Changes

Cohort / File(s) Summary
Dependency versions
apps/cli/src/constants.ts
Bumped @prisma/client and prisma from ^6.13.0^6.15.0; bumped @orpc/server, @orpc/client, @orpc/tanstack-query from ^1.8.4^1.8.6.
MongoDB Prisma templates
apps/cli/templates/db/prisma/mongodb/prisma/schema/schema.prisma, apps/cli/templates/db/prisma/mongodb/prisma/schema/schema.prisma.hbs
Removed static schema; added Handlebars template that includes generator client (provider prisma-client, output = "../generated", moduleFormat = "esm") and datasource db (provider = "mongodb") with conditional runtime lines for bun/node/workers.
MySQL Prisma templates
apps/cli/templates/db/prisma/mysql/prisma/schema/schema.prisma, apps/cli/templates/db/prisma/mysql/prisma/schema/schema.prisma.hbs
Removed static schema; added Handlebars template with generator client and datasource db (provider = "mysql"), plus conditional runtime emission for bun/node/workers.
SQLite Prisma templates
apps/cli/templates/db/prisma/sqlite/prisma/schema/schema.prisma, apps/cli/templates/db/prisma/sqlite/prisma/schema/schema.prisma.hbs
Removed static schema; added Handlebars template with generator client and datasource db (provider = "sqlite"), plus conditional runtime emission for bun/node/workers.
Postgres Prisma template
apps/cli/templates/db/prisma/postgres/prisma/schema/schema.prisma.hbs
Template updated to emit conditional runtime mapping (bun → "bun", node → "nodejs", workers → "workerd"); datasource provider changed from "postgres" to "postgresql".

Sequence Diagram(s)

sequenceDiagram
  autonumber
  actor User
  participant CLI as CLI (project generator)
  participant TPL as Handlebars Template
  participant FS as File System

  User->>CLI: run create/init with DB type + runtime
  CLI->>TPL: select appropriate .prisma.hbs template
  TPL->>TPL: evaluate conditionals (runtime: bun/node/workers)
  TPL->>FS: render and write schema.prisma (generator + datasource [+ runtime])
  FS-->>CLI: schema written
  CLI-->>User: project scaffolding complete
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

Poem

I nibble templates, stitch runtime lines,
Bun, Node, Workers — choices in signs.
Prisma and ORPC hopped their versions new,
I dug out old schemas, planted HBS stew.
Hop, thump, generate — fresh projects bloom. 🐇✨


📜 Recent review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

💡 Knowledge Base configuration:

  • MCP integration is disabled by default for public repositories
  • Jira integration is disabled by default for public repositories
  • Linear integration is disabled by default for public repositories

You can enable these sources in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between cfe23c9 and c8dcfab.

📒 Files selected for processing (1)
  • apps/cli/templates/db/prisma/postgres/prisma/schema/schema.prisma.hbs (1 hunks)
✨ Finishing Touches
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch prisma-runtime-config

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
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

CodeRabbit Commands (Invoked using PR/Issue comments)

Type @coderabbitai help to get the list of available commands.

Other keywords and placeholders

  • Add @coderabbitai ignore or @coderabbit ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Status, Documentation and Community

  • Visit our Status Page to check the current availability of CodeRabbit.
  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

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: 0

Caution

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

⚠️ Outside diff range comments (1)
apps/cli/templates/db/prisma/postgres/prisma/schema/schema.prisma.hbs (1)

16-18: Fix datasource provider: use "postgresql" (not "postgres").

Prisma expects provider = "postgresql" for Postgres. Using "postgres" will break prisma validate/generate.

Apply:

 datasource db {
-  provider = "postgres"
+  provider = "postgresql"
   url      = env("DATABASE_URL")
🧹 Nitpick comments (1)
apps/cli/templates/db/prisma/mongodb/prisma/schema/schema.prisma.hbs (1)

1-14: eq helper is registered; conditional blocks valid
The eq helper is implemented in apps/cli/src/utils/template-processor.ts (line 31), so the {{#if (eq runtime …)}} blocks will work as intended.
Optionally centralize the generator header into a shared partial for reuse across all DB templates.

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

💡 Knowledge Base configuration:

  • MCP integration is disabled by default for public repositories
  • Jira integration is disabled by default for public repositories
  • Linear integration is disabled by default for public repositories

You can enable these sources in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between cbbed09 and cfe23c9.

📒 Files selected for processing (8)
  • apps/cli/src/constants.ts (2 hunks)
  • apps/cli/templates/db/prisma/mongodb/prisma/schema/schema.prisma (0 hunks)
  • apps/cli/templates/db/prisma/mongodb/prisma/schema/schema.prisma.hbs (1 hunks)
  • apps/cli/templates/db/prisma/mysql/prisma/schema/schema.prisma (0 hunks)
  • apps/cli/templates/db/prisma/mysql/prisma/schema/schema.prisma.hbs (1 hunks)
  • apps/cli/templates/db/prisma/postgres/prisma/schema/schema.prisma.hbs (1 hunks)
  • apps/cli/templates/db/prisma/sqlite/prisma/schema/schema.prisma (0 hunks)
  • apps/cli/templates/db/prisma/sqlite/prisma/schema/schema.prisma.hbs (1 hunks)
💤 Files with no reviewable changes (3)
  • apps/cli/templates/db/prisma/mongodb/prisma/schema/schema.prisma
  • apps/cli/templates/db/prisma/sqlite/prisma/schema/schema.prisma
  • apps/cli/templates/db/prisma/mysql/prisma/schema/schema.prisma
🧰 Additional context used
📓 Path-based instructions (3)
**/*.{ts,tsx}

📄 CodeRabbit inference engine (.cursor/rules/convex_rules.mdc)

**/*.{ts,tsx}: Use Id from './_generated/dataModel' to type document ids (e.g., Id<'users'>)
Ensure Record key/value types align with validators (e.g., v.record(v.id('users'), v.string()) => Record<Id<'users'>, string>)
Be strict with types for document ids; prefer Id<'table'> over string
Use 'as const' for string literals in discriminated unions
When using Array and Record types, declare with explicit generic types (e.g., const arr: Array = ...)

In TypeScript, use type aliases (type) instead of interface for type definitions

Files:

  • apps/cli/src/constants.ts
**/*.{js,jsx,ts,tsx,mjs,cjs}

📄 CodeRabbit inference engine (.cursor/rules/use-bun-instead-of-node-vite-npm-pnpm.mdc)

**/*.{js,jsx,ts,tsx,mjs,cjs}: Do not use dotenv; Bun auto-loads .env
Use Bun.serve() for HTTP/WebSockets; do not use express
Use bun:sqlite for SQLite; do not use better-sqlite3
Use Bun.redis for Redis; do not use ioredis
Use Bun.sql for Postgres; do not use pg or postgres.js
Use built-in WebSocket; do not use ws
Prefer Bun.file over node:fs readFile/writeFile
Use Bun.$ instead of execa for shelling out

Files:

  • apps/cli/src/constants.ts
**/*.{js,jsx,ts,tsx}

📄 CodeRabbit inference engine (.cursor/rules/better-t-stack-repo.mdc)

Use normal (function declaration) syntax; do not use arrow functions

Files:

  • apps/cli/src/constants.ts
🔇 Additional comments (9)
apps/cli/src/constants.ts (2)

113-115: Confirm ORPC peer dependency ranges in all templates
ORPC v1.8.6 is imported across every CLI template (React, Svelte, Nuxt, Solid, Native, Next, Fastify, Hono, Express, Elysia). Verify each package.json.hbs or compatibility matrix declares peerDependencies that accommodate ^1.8.6 and update downstream templates as needed.


64-65: Prisma v6.15.0 bump validated: processTemplate is called with the full ProjectConfig (including runtime and dbSetup), and all db/prisma/*/schema.prisma.hbs templates set moduleFormat = "esm" and branch on runtime (bun/nodejs/workerd), matching Prisma 6.15.0’s supported generator options.

apps/cli/templates/db/prisma/sqlite/prisma/schema/schema.prisma.hbs (2)

16-19: LGTM: sqlite datasource block.

Provider/url look correct for sqlite.


1-14: eq helper and runtime context present – no changes required.

apps/cli/templates/db/prisma/mysql/prisma/schema/schema.prisma.hbs (2)

16-19: LGTM: mysql datasource block.

Provider/url are correct.


1-14: Verify runtime context in Prisma template Handlebars eq helper is registered; ensure the runtime property is passed into the template context or the runtime line will be omitted. (Optional) Consolidate the three {{#if}} blocks into a single mapping helper to DRY.

apps/cli/templates/db/prisma/mongodb/prisma/schema/schema.prisma.hbs (1)

16-19: LGTM: mongodb datasource block.

Looks fine.

apps/cli/templates/db/prisma/postgres/prisma/schema/schema.prisma.hbs (2)

5-13: Confirm Prisma runtime defaulteq helper is registered (apps/cli/src/utils/template-processor.ts:31) and RuntimeSchema restricts to “bun” | “node” | “workers” | “none”; templates emit runtime = … only for the first three. If runtime is “none” or unset, the Prisma datasource omits a runtime setting and falls back to Prisma’s default—ensure that default behavior is intended.


19-21: Supabase directUrl: verify env var presence in .env template when dbSetup = "supabase".
I didn’t find a corresponding .env/.env.hbs template—please confirm (or add) a DIRECT_URL= entry so the generated Prisma schema’s env("DIRECT_URL") resolves.

@AmanVarshney01 AmanVarshney01 merged commit a0486c9 into main Sep 3, 2025
1 check was pending
@AmanVarshney01 AmanVarshney01 deleted the prisma-runtime-config branch September 3, 2025 09:59
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