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.
- Local prisma
npm install -g prisma
# npx prisma won't work
- shadow database, otherwise you overwrite your local db
- 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/papermark-shadow-db" --script > prisma/migrations/20240408000000_add_model/migration.sql
- Apply the migration
prisma migrate resolve --applied 20240408000000_add_model