Build cache persisting stale Prisma client after schema change
ryblake89
PROOP

3 months ago

Hi Railway team,

I'm experiencing a persistent build cache issue where my Prisma client is not regenerating properly after a schema change.

**The Problem:**
After removing the `total_matchups` column from my `champion_perspectives` table and updating my Prisma schema, deploys still fail with:

prisma:error Invalid prisma.matchupGuide.update() invocation: The column total_matchups does not exist in the current database.


The database schema is correct (column is dropped), and my `schema.prisma` file is correct. The issue is that the generated Prisma client in `node_modules/.prisma/client/` still contains the old schema definition.

**What I've Tried:**
- Updated postinstall: `"rm -rf node_modules/.prisma && prisma generate"`
- Updated build script: `"rm -rf dist && prisma generate && tsc"`
- Set `NO_CACHE=1` environment variable
- Multiple redeploys
- Redeployed Redis service

**My Current Build Command:**
`npm install && npm run build && npx prisma generate`

**Question:**
Is there a way to completely clear the build cache for my service? Or is deleting and recreating the service the only option?

Thank you!
$20 Bounty

2 Replies

Railway
BOT

3 months ago


3 months ago

This thread has been marked as public for community involvement, as it does not contain any sensitive or personal information. Any further activity in this thread will be visible to everyone.

Status changed to Open brody 3 months ago


3 months ago

I think that the issue is that prisma generate should be run before npm run build, not after it.

You should probably have your pre-deploy command set to npx prisma migrate deploy or something similar as well; this makes sure that before your service starts all the correct migrations are applied.

Recommended Fix:

Update your build command to:

npm install && npx prisma generate && npm run build

Or better yet, update your `package.json` build script to include Prisma generation:

{
  "scripts": {
    "build": "prisma generate && tsc"
  }
}

Then use just:

npm install && npm run build

Loading...