Changes to the schema on production

Alright, so i deployed but no i have to adapt. Still in testing so better get used to how prisma pushes new segments to postgres tables. Case 1 i change a default from false to true Its asking yo reset which we cant do anymore. Trying the prisma migrate --create-only, prisma migrate deploy prisma migrate dev approach But cant seem to work a scriot properly in a monorepo. Read lots of docs and had days worth of conversations with ai. I just want a structure tbat has worked with someone so i can follow and attempt. Since the docs dont seem to be working for me. Any one please
3 Replies
Prisma AI Help
Prisma AI Help3mo ago
Skipping coffee for instant knowledge! Let's brew that AI answer now. Changing a default value in production with Prisma Migrate can be tricky, especially if Prisma prompts you to reset the database—which is not acceptable for production data. Here’s a structure that aligns with the official guidance and community experience: 1. Never use migrate dev in production.
prisma migrate dev is for development only and will prompt for resets if it detects drift or history issues. In production, always use prisma migrate deploy, which never resets the database and only applies unapplied migrations [Prisma Migrate: Development and Production]. 2. If you need to change a default value: - Update your schema.prisma with the new default. - In your development environment, run:
npx prisma migrate dev --name change-default

npx prisma migrate dev --name change-default

This generates a migration file. - Commit the migration file to your repo. 3. Deploy to production: - On your production server, run:
npx prisma migrate deploy

npx prisma migrate deploy

This applies the migration without resetting data [Prisma Migrate: Development and Production]. 4. If you get drift errors or prompts to reset: - Do NOT run migrate dev or db push in production. - Use migrate diff to investigate schema differences:
npx prisma migrate diff --from-schema-datasource prisma/schema.prisma --to-url $DATABASE_URL --shadow-database-url <empty-db-url> --script

npx prisma migrate diff --from-schema-datasource prisma/schema.prisma --to-url $DATABASE_URL --shadow-database-url <empty-db-url> --script

- If needed, manually adjust the migration SQL or use migrate resolve to mark migrations as applied [GitHub Discussion]. 5. Monorepo tip:
Make sure your migration commands are run from the correct package directory, and that your .env and prisma folders are correctly referenced. Summary:
- Only use migrate dev in dev, migrate deploy in prod. - Never reset productio n DB. - Use migrate diff and migrate resolve for advanced drift handling. If you’re still stuck, please share the exact error message or output for more targeted help. 🤔 Alright, thanks for letting us know that there's still some help needed. A team member will reply to you shortly. In the meantime, please let us know any additional info, questions, or which parts of the answer may need clarification.
Grimmjoww231
Grimmjoww231OP3mo ago
will i be able to talk to a team member ?
Nurul
Nurul3mo ago
Can you please elaborate on what change you did to your schema.prisma file and the migration commands you ran?

Did you find this page helpful?