Trouble migrating the schema
Remote contains 3 migrations, same as my local. I have made some changes in the schema and I want to migrate it. But I'm getting this error. (Shown in first image).
But the thing is the changed models shown in the image is not done by me. My friend made those changes but he made a mistake. Instead of migrating the changes. He did
db push directly so the change is not registered in the migration history. But due to this I cannot push my changes in remote.
DB: Postgres
2 Replies
You selected to wait for the human sages. They'll share their wisdom soon.
Grab some tea while you wait, or check out
#ask-ai if you'd like a quick chat with the bot anyway!You would need to generate a migration SQL script that brings your migration history up to date with the current database schema:
You can run something like:
npx prisma migrate diff --from-empty --to-schema-datasource prisma/schema.prisma --script > prisma/migrations/your_migration/migration.sql
After which, since the changes already exist in the database (from db push), you don’t want to re-apply them. Instead, tell Prisma to consider this migration as applied:
npx prisma migrate resolve --applied your_migration