SQLite has no Prisma enums, so removing the enum blocks also dropped the enum
*objects* the app imports from @prisma/client (LinkType.DOCUMENT_LINK, etc.),
crashing Next.js prerender ("Cannot read properties of undefined"). A
build-time step (after `prisma generate`) re-injects the 18 enum objects into
the generated client, so no app files change. Verified: local `next build`
now prerenders all 90 pages.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Create migrations after changes in schema.prisma
So you have made changes to the schema.prisma file and you want to apply those changes to the database.
Chances are you are getting this error from Prisma after running npx prisma migrate dev:
Drift detected: Your database schema is not in sync with your migration history.
...
Do you want to continue? All data will be lost.
Requirements
- Local prisma
npm install -g prisma
# npx prisma won't work
- shadow database, otherwise you overwrite your local db
Steps
- Create a new migration folder
mkdir -p prisma/migrations/20240408000000_add_model
- Generate the migration
prisma migrate diff --from-migrations prisma/migrations --to-schema-datamodel prisma/schema.prisma --shadow-database-url "postgresql://<USER>@localhost:5432/hanzo-dataroom-shadow-db" --script > prisma/migrations/20240408000000_add_model/migration.sql
- Apply the migration
prisma migrate resolve --applied 20240408000000_add_model