-
-
Notifications
You must be signed in to change notification settings - Fork 203
feat(cli): add runtime option in prisma schema #561
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Caution Review failedThe pull request is closed. WalkthroughReplaces 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
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
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Possibly related PRs
Poem
📜 Recent review detailsConfiguration used: CodeRabbit UI Review profile: CHILL Plan: Pro 💡 Knowledge Base configuration:
You can enable these sources in your CodeRabbit configuration. 📒 Files selected for processing (1)
✨ Finishing Touches🧪 Generate unit tests
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. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. CodeRabbit Commands (Invoked using PR/Issue comments)Type Other keywords and placeholders
CodeRabbit Configuration File (
|
There was a problem hiding this 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 breakprisma 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
Theeq
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.
📒 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
UseBun.serve()
for HTTP/WebSockets; do not useexpress
Usebun:sqlite
for SQLite; do not usebetter-sqlite3
UseBun.redis
for Redis; do not useioredis
UseBun.sql
for Postgres; do not usepg
orpostgres.js
Use built-inWebSocket
; do not usews
PreferBun.file
overnode:fs
readFile/writeFile
UseBun.$
instead ofexeca
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 eachpackage.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 fullProjectConfig
(includingruntime
anddbSetup
), and alldb/prisma/*/schema.prisma.hbs
templates setmoduleFormat = "esm"
and branch onruntime
(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
: Verifyruntime
context in Prisma template Handlebarseq
helper is registered; ensure theruntime
property is passed into the template context or theruntime
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 default –eq
helper is registered (apps/cli/src/utils/template-processor.ts:31) andRuntimeSchema
restricts to “bun” | “node” | “workers” | “none”; templates emitruntime = …
only for the first three. Ifruntime
is “none” or unset, the Prisma datasource omits aruntime
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 whendbSetup = "supabase"
.
I didn’t find a corresponding.env
/.env.hbs
template—please confirm (or add) aDIRECT_URL=
entry so the generated Prisma schema’senv("DIRECT_URL")
resolves.
Summary by CodeRabbit
New Features
Chores