Skip to content

Commit bf5144b

Browse files
committed
fix: generate Prisma client locally to fix CI symlink failures
The db:generate script used ln -sfn to symlink generated Prisma files into node_modules/@prisma/client, which fails in CI because pnpm's virtual store is read-only. Changes: - Configure Prisma to output generated client to src/generated/client - Update all imports from @prisma/client to local generated path - Copy generated files to dist/ post-build for runtime resolution - Add db:generate step before build:packages in CI lint job - Add DATABASE_URL env to db:generate steps in CI - Ignore generated/ directory in git
1 parent b09d2be commit bf5144b

8 files changed

Lines changed: 13 additions & 7 deletions

File tree

.github/workflows/ci.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,9 @@ jobs:
2525
cache: 'pnpm'
2626
- run: pnpm install --frozen-lockfile
2727
- run: pnpm format:check
28+
- run: pnpm db:generate
29+
env:
30+
DATABASE_URL: postgresql://veridion:veridion@localhost:5432/veridion_test
2831
- run: pnpm build:packages
2932
- run: pnpm lint
3033

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ pnpm-debug.log*
4343
# Prisma
4444
packages/database/prisma/*.db
4545
packages/database/prisma/*.db-journal
46+
packages/database/src/generated/
4647

4748
# Rust / Soroban
4849
contracts/*/target/

apps/api/src/common/prisma/prisma.service.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { Injectable, OnModuleDestroy, OnModuleInit } from '@nestjs/common';
2-
import type { PrismaClient } from '@prisma/client';
2+
import type { PrismaClient } from '@veridion/database';
33
import { prisma } from '@veridion/database';
44
import { logger } from '@veridion/logger';
55

packages/database/package.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,14 @@
66
"main": "./dist/index.js",
77
"types": "./dist/index.d.ts",
88
"scripts": {
9-
"build": "tsc",
9+
"build": "tsc && cp -r src/generated dist/",
1010
"typecheck": "tsc --noEmit",
11-
"lint": "eslint src/ --max-warnings 0",
12-
"lint:fix": "eslint src/ --fix",
11+
"lint": "eslint src/ --ignore-pattern 'src/generated/**' --max-warnings 0",
12+
"lint:fix": "eslint src/ --ignore-pattern 'src/generated/**' --fix",
1313
"test": "vitest run",
1414
"test:watch": "vitest",
1515
"clean": "rm -rf dist",
16-
"db:generate": "npx prisma generate && ln -sfn ../.prisma node_modules/@prisma/client/.prisma",
16+
"db:generate": "prisma generate",
1717
"db:migrate": "prisma migrate dev",
1818
"db:push": "prisma db push",
1919
"db:seed": "tsx prisma/seed.ts",

packages/database/prisma/schema.prisma

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
generator client {
22
provider = "prisma-client-js"
3+
output = "../src/generated/client"
34
previewFeatures = ["postgresqlExtensions"]
45
}
56

packages/database/src/client.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { PrismaClient } from '@prisma/client';
1+
import { PrismaClient } from './generated/client';
22

33
interface PrismaGlobal {
44
prisma?: PrismaClient;

packages/database/src/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
export { prisma } from './client';
2+
export type { PrismaClient } from './generated/client';
23
export type * from './types';

packages/database/src/types.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import type { Prisma } from '@prisma/client';
1+
import type { Prisma } from './generated/client';
22

33
export type TransactionClient = Prisma.TransactionClient;
44
export type PrismaTx = Omit<Prisma.TransactionClient, '$transaction'>;

0 commit comments

Comments
 (0)