I'm confused about the development team workflow for development to production database migrations. The docs are pretty decent but there's some gaps in my mind about the proper way to do a production deploy without data loss.
My thought is why would dropping data in development ever be acceptable, because you'll end up with a migration script that will fail in production (because prisma migrate deploy never drops data but fails instead.. correct or can it???).
What is the proper dev to prod team convention for Prisma migrations? This is my thinking:
- Use
db pushlocally; NEVER accept data loss - When happy with schema changes, run
migrate dev --create-only - Adjust migration scripts to avoid data loss; if data loss is necessary, change the SQL so it creates temporary tables to move the data while schema is changed, then move data back?
- Run
migrate devlocally to apply migrations to local database; NEVER accept data loss - Deploy code and run
migrate deployin production
Is this best practices or is there a better way to do this? I don't see why migrations that require dropped data should ever make it into source control, but maybe I'm missing something. Any help or experience would be greatly appreciated!