Skip to content

feat(prisma): Prep v6 for v7 upgrade#1256

Merged
Tobbe merged 14 commits intomainfrom
tobbe-major-prisma-v6-7-prep
Feb 26, 2026
Merged

feat(prisma): Prep v6 for v7 upgrade#1256
Tobbe merged 14 commits intomainfrom
tobbe-major-prisma-v6-7-prep

Conversation

@Tobbe
Copy link
Copy Markdown
Member

@Tobbe Tobbe commented Feb 25, 2026

This PR prepares for Prisma v7 by introducing an indirection layer for all Prisma imports. Prisma v7 will change where the generated client lives (from @prisma/client to a local project path like ./generated/prisma/), which would normally require rewriting imports across every service, test, and scenario file.

This PR makes the import change now (if you want), while still on v6, to isolate major code changes from the Prisma v7 upgrade, to make it easier to debug any issues (fewer moving parts). The PR does that by making src/lib/db re-export everything from Prisma, then point all consumer code at src/lib/db instead of @prisma/client. This is done now on v6 where both paths work, so the change can be validated safely. When v7 lands, only one line in db.ts needs to change:

// v6 (this PR)
export * from '@prisma/client'
// v7 (future PR)
export * from './generated/prisma/client.js'

The PR touches four areas:

db.ts templates
Adds export * from '@prisma/client' so src/lib/db becomes a superset of @prisma/client

Generator templates & codegen
Newly generated services, tests, scenarios, and GraphQL type files now import from src/lib/db instead of @prisma/client

A jscodeshift codemod
prismaV7Prep.ts automates the migration for existing user projects

All fixture/test-project files
Updated to match the new pattern

@netlify
Copy link
Copy Markdown

netlify Bot commented Feb 25, 2026

Deploy Preview for cedarjs canceled.

Name Link
🔨 Latest commit b97c73e
🔍 Latest deploy log https://app.netlify.com/projects/cedarjs/deploys/69a07daf8187350008c56526

@github-actions github-actions Bot added this to the next-release milestone Feb 25, 2026
@nx-cloud
Copy link
Copy Markdown

nx-cloud Bot commented Feb 25, 2026

🤖 Nx Cloud AI Fix

Ensure the fix-ci command is configured to always run in your CI pipeline to get automatic fixes in future runs. For more information, please see https://nx.dev/ci/features/self-healing-ci


View your CI Pipeline Execution ↗ for commit b97c73e

Command Status Duration Result
nx run-many -t test --minWorkers=1 --maxWorkers=4 ✅ Succeeded 1m 52s View ↗
nx run-many -t test:types ✅ Succeeded 6s View ↗
nx run-many -t build:pack --exclude create-ceda... ✅ Succeeded 8s View ↗
nx run-many -t build ✅ Succeeded 8s View ↗

☁️ Nx Cloud last updated this comment at 2026-02-26 17:24:33 UTC

@greptile-apps
Copy link
Copy Markdown
Contributor

greptile-apps Bot commented Feb 25, 2026

Greptile Summary

Prepares Cedar for Prisma v7 by centralizing all Prisma imports through src/lib/db, making the eventual v7 upgrade a one-line change.

Major Changes:

  • Added export * from '@prisma/client' to all db.ts/db.js files
  • Updated all generator templates (service scenarios, tests, data migrations) to import from src/lib/db
  • Updated GraphQL codegen to emit imports from src/lib/db (API) and $api/src/lib/db (web)
  • Created a new codemod (prismaV7Prep) to help users migrate their existing projects
  • Comprehensive migration documentation in prisma-v6-to-v7-step-1.md

Critical Issues Found:

  • 11 scenario files in __fixtures__ have duplicated content (every line appears twice), causing syntax errors
  • Affected fixtures: test-project, test-project-live, and esm-test-project
  • Files with duplications: *.scenarios.ts files for contacts, posts, users, and describeContacts
  • The templates and test-project/ (root) are correct—only __fixtures__/ directories are affected

Confidence Score: 1/5

  • This PR cannot be merged due to critical syntax errors in 11 fixture files
  • While the approach is sound and templates/codemods are correct, 11 scenario files have completely duplicated content causing syntax errors. These must be fixed before merge.
  • All scenario files in __fixtures__/test-project, __fixtures__/test-project-live, and __fixtures__/esm-test-project need immediate attention to remove duplicated lines

Important Files Changed

Filename Overview
fixtures/test-project/api/src/services/contacts/contacts.scenarios.ts Duplicated scenario content causing syntax errors throughout file
fixtures/test-project/api/src/services/posts/posts.scenarios.ts Duplicated scenario content causing syntax errors throughout file
fixtures/test-project-live/api/src/services/contacts/contacts.scenarios.ts Duplicated scenario content causing syntax errors throughout file
fixtures/esm-test-project/api/src/services/posts/posts.scenarios.ts Duplicated scenario content causing syntax errors throughout file
packages/codemods/src/codemods/v2.7.x/prismaV7Prep/prismaV7Prep.ts New codemod to help users migrate Prisma imports to src/lib/db
packages/create-cedar-app/templates/ts/api/src/lib/db.ts Added export * from '@prisma/client' to enable re-exporting pattern
packages/internal/src/generate/graphqlCodeGen.ts Updated GraphQL codegen to import Prisma from src/lib/db instead of @prisma/client

Flowchart

%%{init: {'theme': 'neutral'}}%%
flowchart TD
    A[User Code] -->|Before: import from| B["@prisma/client"]
    A -->|After: import from| C["src/lib/db"]
    C -->|Re-exports| B
    
    D[Generator Templates] -->|Generate code with| C
    E[GraphQL Codegen] -->|Generates types from| C
    F[Codemod] -->|Migrates imports to| C
    
    C -->|Prisma v7: switch to| G["../db/generated/prisma/client.js"]
    
    style B fill:#f9f,stroke:#333
    style C fill:#9f9,stroke:#333
    style G fill:#99f,stroke:#333
Loading

Last reviewed commit: e38a132

Copy link
Copy Markdown
Contributor

@greptile-apps greptile-apps Bot left a comment

Choose a reason for hiding this comment

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

54 files reviewed, 11 comments

Edit Code Review Agent Settings | Greptile

Comment thread __fixtures__/test-project/api/src/services/posts/posts.scenarios.ts
Comment thread __fixtures__/test-project/api/src/services/users/users.scenarios.ts
@Tobbe Tobbe merged commit 8562e88 into main Feb 26, 2026
41 checks passed
@Tobbe Tobbe deleted the tobbe-major-prisma-v6-7-prep branch February 26, 2026 17:27
Tobbe added a commit that referenced this pull request Mar 1, 2026
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