Skip to content

fix: repair Prisma setup migration flow#35

Merged
AmanVarshney01 merged 7 commits intomainfrom
aman/create-prisma-setup-bugfixes
Apr 29, 2026
Merged

fix: repair Prisma setup migration flow#35
AmanVarshney01 merged 7 commits intomainfrom
aman/create-prisma-setup-bugfixes

Conversation

@AmanVarshney01
Copy link
Copy Markdown
Member

@AmanVarshney01 AmanVarshney01 commented Apr 25, 2026

Summary

  • add the non-Compute migrate + seed setup flow behind --migrate-and-seed / --no-migrate-and-seed
  • run migrate/seed from the resolved Prisma project directory, so monorepo templates work too
  • import dotenv/config in Prisma config templates for Bun/Node runtimes so env("DATABASE_URL") works during CLI commands

Test Plan

  • bun run format
  • bun run typecheck
  • bun run lint
  • bun run format:check
  • bun run build
  • no-install scaffold smoke: Hono + Bun + SQLite

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Apr 25, 2026

Note

Reviews paused

It 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 reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review

Walkthrough

Adds a migrate+seed option to the Prisma setup flow and Deno/libsql support: introduces shouldMigrateAndSeed, computes availability, runs a new migrate+seed routine with conditional warnings and guidance, bumps Prisma deps to ^7.8.0 (adds libsql), and makes many templates package-manager-aware (seed commands, dotenv import, sqlite adapter selection).

Changes

Cohort / File(s) Summary
Prisma setup & types
src/tasks/setup-prisma.ts, src/types.ts
Adds shouldMigrateAndSeed:boolean to context/schema; computes whether migration+seeding is possible, optionally prompts, runs migrateAndSeedIfRequested after client generation, reports didMigrate/didSeed, updates warnings/next-steps; adds Postgres-first-migration delay.
Helpers & runtime utilities
src/templates/shared.ts, src/utils/runtime.ts
Registers new Handlebars helpers (seedCommand, sqliteAdapterClass, sqliteAdapterPackage, requiresPrismaConfigDotenvImport); adds requiresPrismaConfigDotenvImport(packageManager) utility for template dotenv import decisions.
Dependency & DB package logic
src/constants/dependencies.ts, src/constants/db-packages.ts, src/tasks/install.ts
Bumps Prisma packages to ^7.8.0, adds @prisma/adapter-libsql, removes node-gyp; getDbPackages now accepts optional packageManager and returns libsql for deno/sqlite; centralizes Deno Prisma CLI command generation and adjusts dependency writes.
Templates — Prisma configs
templates/create/*/prisma.config.ts.hbs, templates/create/*/prisma.config.ts, templates/create/tanstack-start/prisma.config.ts.hbs, templates/create/tanstack-start/prisma.config.ts, templates/create/turborepo/.../prisma.config.ts.hbs, templates/create/turborepo/.../prisma.config.ts
Converts/updates framework Prisma config files to use requiresPrismaConfigDotenvImport and seedCommand helper for package-manager-aware dotenv import and seed commands; some static config files replaced by Handlebars templates.
Templates — seed scripts
templates/create/*/prisma/seed.ts.hbs, templates/create/*/prisma/seed.ts
Seed templates updated to be package-manager-aware: conditional import paths/extensions, Deno Deno.exit(1) vs process.exit(1), and runtime-specific control flow; some seeds now import shared prisma client.
Templates — Prisma client modules
templates/create/*/src/lib/prisma.ts.hbs, templates/create/*/src/lib/server/prisma.ts.hbs, templates/create/*/src/lib/prisma.server.ts.hbs
Client templates now select sqlite adapter package/class via helpers (Deno libsql vs better-sqlite3), adjust PrismaClient import extension for Deno, and centralize DATABASE_URL retrieval (Deno.env vs process.env) with sqlite fallbacks.
Framework-specific adjustments
templates/create/svelte/..., templates/create/next/..., templates/create/nest/..., templates/create/astro/..., templates/create/elysia/..., templates/create/hono/..., templates/create/nuxt/..., templates/create/tanstack-start/..., templates/create/turborepo/...
Multiple framework templates updated to the new helpers and Deno-aware patterns: dotenv conditional imports, seedCommand usage, adapter selection, import path extensions, client reuse, and adjusted seed error handling.
Removed/added template files
templates/create/tanstack-start/prisma.config.ts (removed), templates/create/tanstack-start/prisma.config.ts.hbs (added), templates/create/turborepo/.../prisma.config.ts (removed), templates/create/turborepo/.../prisma.config.ts.hbs (added)
Replaced static Prisma config files with Handlebars templates that emit package-manager-aware configs and seed commands.

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~45 minutes

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title 'fix: repair Prisma setup migration flow' directly and clearly describes the main objective of the PR, which is fixing the Prisma migration setup flow as confirmed by the PR objectives.
Description check ✅ Passed The description is directly related to the changeset, detailing the three main changes: adding migrate+seed flow behind CLI flags, running from resolved Prisma project directory for monorepo support, and importing dotenv/config in templates.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

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

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch aman/create-prisma-setup-bugfixes
✨ Simplify code
  • Create PR with simplified code
  • Commit simplified code in branch aman/create-prisma-setup-bugfixes

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

@github-actions
Copy link
Copy Markdown

github-actions Bot commented Apr 25, 2026

PR preview published

  • Version: 0.4.1-pr.35.74.1
  • Tag: pr35
  • Run with Bun: bunx create-prisma@pr35
  • Run with npm: npx create-prisma@pr35
  • Run with Yarn: yarn dlx create-prisma@pr35
  • Run with pnpm: pnpm dlx create-prisma@pr35
  • Run with Deno: deno run -A npm:create-prisma@pr35
  • Workflow run: https://github.com/prisma/create-prisma/actions/runs/25006921060

Copy link
Copy Markdown

@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

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@src/tasks/setup-prisma.ts`:
- Around line 776-782: The if-block checking options.databaseUrl is dead because
callers compute databaseUrl with a fallback to getDefaultDatabaseUrl(), which
always returns a string; remove the dead guard block that returns
didMigrate/didSeed/warning and its surrounding conditional in setupPrisma
(references: options.databaseUrl, getDefaultDatabaseUrl, the migrate+seed return
object) so migration/seed logic always proceeds, or alternatively change the
callers that construct options.databaseUrl to pass undefined when no real DB URL
exists; pick one approach and update callers or delete this unreachable branch
accordingly.
- Around line 796-798: Add an explanatory comment above the conditional that
waits when context.shouldUsePrismaPostgres is true (the await new
Promise((resolve) => setTimeout(resolve, 2000)) block) describing that the
hardcoded 2-second delay is a deliberate workaround for a known race condition
during Prisma Postgres provisioning, include the issue/PR reference or repro
notes if available, state what could be done to safely remove or shorten the
delay (e.g., replace with an explicit readiness probe or retry loop checking DB
connectivity), and mark it with a TODO and date so future maintainers know why
it exists and how to revisit it.
🪄 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: Organization UI

Review profile: ASSERTIVE

Plan: Pro

Run ID: a78db60a-cfe1-40c3-8048-d62125532f3a

📥 Commits

Reviewing files that changed from the base of the PR and between 37d3e83 and 5fdb572.

📒 Files selected for processing (7)
  • src/tasks/setup-prisma.ts
  • src/templates/shared.ts
  • src/types.ts
  • src/utils/runtime.ts
  • templates/create/elysia/prisma.config.ts.hbs
  • templates/create/hono/prisma.config.ts.hbs
  • templates/create/nest/prisma.config.ts.hbs

Comment thread src/tasks/setup-prisma.ts Outdated
Comment thread src/tasks/setup-prisma.ts
Copy link
Copy Markdown

@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: 3

♻️ Duplicate comments (2)
src/tasks/setup-prisma.ts (2)

787-793: ⚠️ Potential issue | 🟡 Minor

Dead code: databaseUrl always has a fallback value.

At the call site (lines 738-741), databaseUrl is computed with a fallback chain ending in getDefaultDatabaseUrl(), which always returns a string. This guard will never trigger.

Remove this unreachable block:

Proposed fix
   if (!options.didGenerateClient) {
     return {
       didMigrate: false,
       didSeed: false,
       warning: "Skipped migrate + seed because the Prisma Client was not generated.",
     };
   }
-  if (!options.databaseUrl) {
-    return {
-      didMigrate: false,
-      didSeed: false,
-      warning: "Skipped migrate + seed because no DATABASE_URL is available.",
-    };
-  }
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/tasks/setup-prisma.ts` around lines 787 - 793, The if-check guarding
options.databaseUrl is unreachable because databaseUrl is always set via the
fallback chain ending in getDefaultDatabaseUrl(); remove the entire conditional
block that returns didMigrate/didSeed warning and any now-unused local
references tied only to that branch. Update surrounding control flow in the
setupPrisma/task function (references: options.databaseUrl,
getDefaultDatabaseUrl) so execution continues normally without this dead return.

807-809: 🧹 Nitpick | 🔵 Trivial

Add a comment explaining the 2-second delay.

This hardcoded delay appears to be a workaround for Prisma Postgres provisioning timing. Without documentation, future maintainers won't understand why it exists or when it can be removed.

Proposed documentation
   try {
     if (context.shouldUsePrismaPostgres) {
+      // Brief delay to allow newly provisioned Prisma Postgres database to become reachable.
+      // TODO: Replace with an explicit readiness check or retry loop.
       await new Promise((resolve) => setTimeout(resolve, 2000));
     }
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/tasks/setup-prisma.ts` around lines 807 - 809, The 2-second hardcoded
wait after checking context.shouldUsePrismaPostgres is a magic-number workaround
for Prisma Postgres provisioning timing; add a clear comment directly above the
if block (the check using context.shouldUsePrismaPostgres and the await new
Promise((resolve) => setTimeout(resolve, 2000))) that explains why the delay is
required, under what conditions it can be removed, and link to any related
issue/PR or external doc; optionally replace the literal 2000 with a named
constant like PRISMA_PROVISION_DELAY_MS to make intent explicit.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@templates/create/astro/prisma.config.ts.hbs`:
- Line 10: Extract the nested inline Handlebars logic that builds the Prisma
seed string into a helper (e.g., seedCommand) or multiline conditional to
improve readability and unify the seed path; update the template reference where
the seed is set (the seed: "..." line in the template) to call the new helper or
use the expanded if/else blocks, ensure all branches use a consistent path
format like "./prisma/seed.ts", and add the helper implementation in the shared
template helpers module (for example src/templates/shared.ts) so all templates
can reuse it.

In `@templates/create/astro/src/lib/prisma.ts.hbs`:
- Line 1: The Handlebars helper calls in this template use an implicit
packageManager reference (see usages of requiresDotenvConfigImport and other
helper invocations at the instances around lines 1, 15, and 45); update those
helper calls to reference the context explicitly by using this.packageManager
(e.g., pass this.packageManager to requiresDotenvConfigImport and any other
helpers that currently rely on packageManager) so the template binds the correct
context and avoids ambiguity when rendering.

In `@templates/create/nuxt/prisma.config.ts.hbs`:
- Line 10: The seed command's path is inconsistent: when packageManager is
"deno" or "bun" it uses "./prisma/seed.ts" but the tsx fallback uses
"prisma/seed.ts"; update the tsx branch in the seed template (the seed: line
that checks packageManager and selects tsx) to use the leading "./" so all
branches consistently reference "./prisma/seed.ts".

---

Duplicate comments:
In `@src/tasks/setup-prisma.ts`:
- Around line 787-793: The if-check guarding options.databaseUrl is unreachable
because databaseUrl is always set via the fallback chain ending in
getDefaultDatabaseUrl(); remove the entire conditional block that returns
didMigrate/didSeed warning and any now-unused local references tied only to that
branch. Update surrounding control flow in the setupPrisma/task function
(references: options.databaseUrl, getDefaultDatabaseUrl) so execution continues
normally without this dead return.
- Around line 807-809: The 2-second hardcoded wait after checking
context.shouldUsePrismaPostgres is a magic-number workaround for Prisma Postgres
provisioning timing; add a clear comment directly above the if block (the check
using context.shouldUsePrismaPostgres and the await new Promise((resolve) =>
setTimeout(resolve, 2000))) that explains why the delay is required, under what
conditions it can be removed, and link to any related issue/PR or external doc;
optionally replace the literal 2000 with a named constant like
PRISMA_PROVISION_DELAY_MS to make intent explicit.
🪄 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: Organization UI

Review profile: ASSERTIVE

Plan: Pro

Run ID: aefa64d4-d75b-4da5-963e-70241280cade

📥 Commits

Reviewing files that changed from the base of the PR and between 5fdb572 and 9270449.

📒 Files selected for processing (32)
  • src/constants/db-packages.ts
  • src/constants/dependencies.ts
  • src/tasks/install.ts
  • src/tasks/setup-prisma.ts
  • src/templates/shared.ts
  • templates/create/astro/prisma.config.ts
  • templates/create/astro/prisma.config.ts.hbs
  • templates/create/astro/prisma/seed.ts.hbs
  • templates/create/astro/src/lib/prisma.ts.hbs
  • templates/create/elysia/src/lib/prisma.ts.hbs
  • templates/create/hono/src/lib/prisma.ts.hbs
  • templates/create/nest/src/lib/prisma.ts.hbs
  • templates/create/next/prisma.config.ts
  • templates/create/next/prisma.config.ts.hbs
  • templates/create/next/prisma/seed.ts.hbs
  • templates/create/next/src/lib/prisma.ts.hbs
  • templates/create/nuxt/prisma.config.ts
  • templates/create/nuxt/prisma.config.ts.hbs
  • templates/create/nuxt/prisma/seed.ts.hbs
  • templates/create/nuxt/server/utils/prisma.ts.hbs
  • templates/create/svelte/prisma.config.ts
  • templates/create/svelte/prisma.config.ts.hbs
  • templates/create/svelte/prisma/seed.ts.hbs
  • templates/create/svelte/src/lib/server/prisma.ts.hbs
  • templates/create/tanstack-start/prisma.config.ts
  • templates/create/tanstack-start/prisma.config.ts.hbs
  • templates/create/tanstack-start/prisma/seed.ts.hbs
  • templates/create/tanstack-start/src/lib/prisma.server.ts.hbs
  • templates/create/turborepo/packages/db/prisma.config.ts
  • templates/create/turborepo/packages/db/prisma.config.ts.hbs
  • templates/create/turborepo/packages/db/prisma/seed.ts.hbs
  • templates/create/turborepo/packages/db/src/client.ts.hbs
💤 Files with no reviewable changes (6)
  • templates/create/next/prisma.config.ts
  • templates/create/nuxt/prisma.config.ts
  • templates/create/turborepo/packages/db/prisma.config.ts
  • templates/create/svelte/prisma.config.ts
  • templates/create/tanstack-start/prisma.config.ts
  • templates/create/astro/prisma.config.ts

Comment thread templates/create/astro/prisma.config.ts.hbs Outdated
Comment thread templates/create/astro/src/lib/prisma.ts.hbs Outdated
Comment thread templates/create/nuxt/prisma.config.ts.hbs Outdated
Copy link
Copy Markdown

@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: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@src/tasks/setup-prisma.ts`:
- Around line 810-811: Update the hardcoded fallback messages that tell users to
run `prisma migrate dev` and `prisma db seed` to instead reference the
package.json scripts `db:migrate` and `db:seed` so they match the rest of the
code (e.g., the messages created near the warning object around the string
"Migration failed; run `prisma migrate dev --name init` manually." and any
similar message at the later occurrence). Replace the literal CLI commands in
those warning strings with the npm script names (`npm run db:migrate` / `npm run
db:seed` or just `db:migrate`/`db:seed` consistent with
buildNextStepsForContext) so the messages are consistent with
buildNextStepsForContext and other user-facing next-step instructions.
🪄 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: Organization UI

Review profile: ASSERTIVE

Plan: Pro

Run ID: 1e77205e-a77c-43e8-ad54-884275fa82d9

📥 Commits

Reviewing files that changed from the base of the PR and between 9270449 and bb65b3b.

📒 Files selected for processing (3)
  • src/constants/dependencies.ts
  • src/tasks/install.ts
  • src/tasks/setup-prisma.ts

Comment thread src/tasks/setup-prisma.ts Outdated
Copy link
Copy Markdown

@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: 13

♻️ Duplicate comments (1)
templates/create/astro/src/lib/prisma.ts.hbs (1)

4-4: ⚠️ Potential issue | 🟠 Major

Complete the previous no-implicit-this cleanup in this template.

Good partial fix, but Line 4 and Line 21 still use implicit packageManager (and Line 22 uses implicit provider), so lint still fails.

🛠️ Suggested patch
-import { PrismaClient } from "../generated/prisma/client{{`#if` (eq packageManager "deno")}}.ts{{/if}}";
+import { PrismaClient } from "../generated/prisma/client{{`#if` (eq this.packageManager "deno")}}.ts{{/if}}";
@@
-const rawDatabaseUrl = {{`#if` (eq packageManager "deno")}}Deno.env.get("DATABASE_URL"){{else}}import.meta.env?.DATABASE_URL ?? process.env.DATABASE_URL{{/if}};
-{{`#if` (eq provider "sqlite")}}
+const rawDatabaseUrl = {{`#if` (eq this.packageManager "deno")}}Deno.env.get("DATABASE_URL"){{else}}import.meta.env?.DATABASE_URL ?? process.env.DATABASE_URL{{/if}};
+{{`#if` (eq this.provider "sqlite")}}

Also applies to: 21-22

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@templates/create/astro/src/lib/prisma.ts.hbs` at line 4, The template uses
implicit Handlebars variables packageManager and provider which breaks
no-implicit-this; update the three occurrences to reference the root context
explicitly (e.g. replace packageManager with `@root.packageManager` and provider
with `@root.provider`) so the import line and the other usages use
`@root.packageManager` and `@root.provider` instead of implicit names.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@templates/create/astro/prisma/seed.ts.hbs`:
- Line 1: The Handlebars template uses implicit `packageManager` references
(e.g., in the import line's conditional and the block around lines 37-41 using
`(eq packageManager "deno")`), which violates no-implicit-this; fix by replacing
those implicit references with explicit root lookups like `@root.packageManager`
(e.g., change `{{`#if` (eq packageManager "deno")}}` to `{{`#if` (eq
`@root.packageManager` "deno")}}` and similarly update the import conditional),
and ensure every occurrence of `packageManager` in Handlebars expressions in
this template is converted to `@root.packageManager`.

In `@templates/create/nest/prisma/seed.ts.hbs`:
- Line 1: The import line in the seed template uses an unqualified Handlebars
variable packageManager; update that conditional to use this.packageManager
(i.e., replace occurrences of packageManager with this.packageManager in the
seed template's import conditional) so scoping matches other templates and
preserves consistency across templates (e.g., where this.packageManager is
already used).

In `@templates/create/nest/src/lib/prisma.ts.hbs`:
- Around line 56-63: The file instantiates a PrismaClient singleton at module
load (const prisma = createPrismaClient()) which runs whenever
prismaClientOptions is imported (e.g., by PrismaService) and can create an
unwanted client; remove the top-level instantiation and either (A) export only
createPrismaClient and have callers (or a dedicated prisma singleton module)
create/hold the app-wide client lazily, or (B) move the seed-only client into a
separate module used only by seeding code, or implement a lazy getter like
getPrismaSingleton that calls createPrismaClient on first use; update imports in
PrismaService to use createPrismaClient/getPrismaSingleton or the new seed
module so no client is created during shared runtime import.

In `@templates/create/next/prisma/seed.ts.hbs`:
- Line 1: The Handlebars template uses the implicit `packageManager` in the
import and later block (in templates/create/next/prisma/seed.ts.hbs at the top
import and the block around lines 37-41); update those `{{`#if` (eq packageManager
"deno")}}`/`{{/if}}` usages to reference the explicit context (e.g.,
`../packageManager`) so they comply with the no-implicit-this rule and continue
to use the `eq` helper; make the same explicit-context change for every
occurrence in the file (the import line and the conditional block around lines
37-41).

In `@templates/create/next/src/lib/prisma.ts.hbs`:
- Around line 1-4: Change all implicit references to packageManager to use the
explicit argument form so the template passes the no-implicit-this lint: replace
packageManager with `@packageManager` in the requiresDotenvConfigImport(...) call,
in the import path string interpolation, and in the eq(...) helper usages (i.e.
update requiresDotenvConfigImport packageManager → requiresDotenvConfigImport
`@packageManager`, eq packageManager "deno" → eq `@packageManager` "deno", and any
other packageManager bare identifiers). This touches the
requiresDotenvConfigImport helper call, the import from
"../generated/prisma/client{{`#if` (eq packageManager "deno")}}.ts{{/if}}", and
every eq/conditional that uses packageManager; ensure all occurrences use
`@packageManager` to satisfy ember-template-lint no-implicit-this.

In `@templates/create/nuxt/prisma/seed.ts.hbs`:
- Line 1: The Handlebars template uses bare packageManager in two conditionals
(the import line referencing prisma and the block around lines 37–41), which
violates no-implicit-this; update both conditionals to reference
this.packageManager instead (e.g., change occurrences of {{`#if` (eq
packageManager "deno")}} and any other packageManager checks to {{`#if` (eq
this.packageManager "deno")}}) so the template explicitly reads from the current
context.

In `@templates/create/nuxt/server/utils/prisma.ts.hbs`:
- Around line 1-4: Update the Handlebars template to use an explicit
this-context for packageManager: replace every implicit packageManager reference
(e.g. in the block helper call {{`#if` (requiresDotenvConfigImport
packageManager)}}, the conditional {{`#if` (eq packageManager "deno")}}, and any
other occurrences) with this.packageManager so the helpers become {{`#if`
(requiresDotenvConfigImport this.packageManager)}}, {{`#if` (eq
this.packageManager "deno")}}, etc.; ensure all occurrences mentioned (imports,
PrismaClient path conditional, and the other conditional uses) are changed
consistently to avoid no-implicit-this lint errors.

In `@templates/create/svelte/prisma/seed.ts.hbs`:
- Line 1: Update the Handlebars template to avoid implicit this references by
changing any occurrences of packageManager to this.packageManager: specifically
update the import line (current import prisma ... {{`#if` (eq packageManager
"deno")}}) to use {{`#if` (eq this.packageManager "deno")}} and update the block
around lines 37-41 where packageManager is checked/used to use
this.packageManager instead so all template helpers reference the explicit this
context.

In `@templates/create/svelte/src/lib/server/prisma.ts.hbs`:
- Line 1: The template uses implicit Handlebars context for packageManager and
provider (e.g., the PrismaClient import line and other template spots
referencing packageManager/provider); update all occurrences to use explicit
this.* references (replace packageManager with this.packageManager and provider
with this.provider) so the import string and any conditional blocks (the import
line with PrismaClient, the blocks around provider usage, and the other template
spots) use this.packageManager and this.provider consistently to satisfy
no-implicit-this.

In `@templates/create/tanstack-start/prisma/seed.ts.hbs`:
- Line 1: Update the Handlebars checks to use an explicit context path instead
of implicit packageManager references: change occurrences like {{`#if` (eq
packageManager "deno")}} and any direct {{packageManager}} uses to {{`#if` (eq
this.packageManager "deno")}} (or {{this.packageManager}}) so the import line
import "../src/lib/prisma.server{{`#if` (eq packageManager "deno")}}.ts{{/if}}";
and the check at line 37 reference this.packageManager explicitly to satisfy the
no-implicit-this lint rule.

In `@templates/create/tanstack-start/src/lib/prisma.server.ts.hbs`:
- Line 1: The template uses implicit `packageManager` usage (e.g. in the helper
call `requiresDotenvConfigImport packageManager`) which triggers
no-implicit-this lint errors; update all occurrences to use explicit context
(replace `packageManager` with `this.packageManager`) wherever it appears in
this template (including the `requiresDotenvConfigImport` call and the other
spots noted) so the Handlebars helper invocations and references are explicit
and lint-clean.
- Line 15: The helper that returns the SQLite adapter
(sqliteAdapterClass/sqliteAdapterPackage) currently maps Bun to
`@prisma/adapter-better-sqlite3` which is incompatible with Bun; update the
mapping logic in the helper in src/templates/shared.ts so that when the runtime
or package manager is Bun it returns `@prisma/adapter-libsql` and the
corresponding class name (instead of adapter-better-sqlite3), and ensure any
callers (e.g., the template usage referencing sqliteAdapterClass and
sqliteAdapterPackage) pick up the new values so Bun+SQLite projects generate
with `@prisma/adapter-libsql`.

In `@templates/create/turborepo/packages/db/src/client.ts.hbs`:
- Around line 1-2: Refactor the duplicate Deno branching in the Handlebars
template by replacing the paired "{{`#if` (eq packageManager \"deno\")}} ...
{{else}} ... {{/if}}" usages with a single inverse-style conditional (e.g., use
"{{`#unless` (eq packageManager \"deno\")}} ... {{/unless}}" or equivalent) in
both occurrences around the "{{`#if` (eq packageManager \"deno\")}}" block and the
second block at lines 24-28 so the template reads more clearly and avoids
duplicated branching logic.

---

Duplicate comments:
In `@templates/create/astro/src/lib/prisma.ts.hbs`:
- Line 4: The template uses implicit Handlebars variables packageManager and
provider which breaks no-implicit-this; update the three occurrences to
reference the root context explicitly (e.g. replace packageManager with
`@root.packageManager` and provider with `@root.provider`) so the import line and
the other usages use `@root.packageManager` and `@root.provider` instead of implicit
names.
🪄 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: Organization UI

Review profile: ASSERTIVE

Plan: Pro

Run ID: 2e6628b6-ed17-4b61-82d5-c4e80cdf6114

📥 Commits

Reviewing files that changed from the base of the PR and between 7595a91 and 576efe3.

📒 Files selected for processing (14)
  • templates/create/astro/prisma/seed.ts.hbs
  • templates/create/astro/src/lib/prisma.ts.hbs
  • templates/create/nest/prisma/seed.ts.hbs
  • templates/create/nest/src/lib/prisma.ts.hbs
  • templates/create/next/prisma/seed.ts.hbs
  • templates/create/next/src/lib/prisma.ts.hbs
  • templates/create/nuxt/prisma/seed.ts.hbs
  • templates/create/nuxt/server/utils/prisma.ts.hbs
  • templates/create/svelte/prisma/seed.ts.hbs
  • templates/create/svelte/src/lib/server/prisma.ts.hbs
  • templates/create/tanstack-start/prisma/seed.ts.hbs
  • templates/create/tanstack-start/src/lib/prisma.server.ts.hbs
  • templates/create/turborepo/packages/db/prisma/seed.ts.hbs
  • templates/create/turborepo/packages/db/src/client.ts.hbs

Comment thread templates/create/astro/prisma/seed.ts.hbs
Comment thread templates/create/nest/prisma/seed.ts.hbs Outdated
Comment thread templates/create/nest/src/lib/prisma.ts.hbs Outdated
Comment thread templates/create/next/prisma/seed.ts.hbs
Comment thread templates/create/next/src/lib/prisma.ts.hbs
Comment thread templates/create/svelte/src/lib/server/prisma.ts.hbs
Comment thread templates/create/tanstack-start/prisma/seed.ts.hbs
Comment thread templates/create/tanstack-start/src/lib/prisma.server.ts.hbs
Comment thread templates/create/tanstack-start/src/lib/prisma.server.ts.hbs
Comment thread templates/create/turborepo/packages/db/src/client.ts.hbs Outdated
@AmanVarshney01
Copy link
Copy Markdown
Member Author

Addressed the real template issues in ade9b0e: Nest no longer creates an eager PrismaClient singleton, and the Turborepo template uses the cleaner inverse conditional. I am keeping the bare Handlebars context style instead of switching only these files to this.packageManager/this.provider: the repo does not run ember-template-lint/no-implicit-this, existing templates already use bare context, and the rendered output is unchanged.

@AmanVarshney01 AmanVarshney01 merged commit 7673ba2 into main Apr 29, 2026
6 checks passed
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