James
05/30/2021, 11:53 PMKeanu Gargar
05/31/2021, 2:10 AMmigrate removes the data? i don’t think so.
For me, It only removes the data if i use --reset .James
05/31/2021, 2:14 AMJames
05/31/2021, 2:16 AMKeanu Gargar
05/31/2021, 2:26 AMnpx prisma migrate dev --name "migration name" to create migrations whenever i have changes to the db structure.
Here’s a sample i did just now, i tested creating a new column called testColumn and did the command above. Here’s the full result from cli:
/usr/app # npx prisma migrate dev --name add test column
Environment variables loaded from .env
Prisma schema loaded from prisma/schema.prisma
Datasource "db": PostgreSQL database "test-db", schema "public" at "db:5432"
The following migration(s) have been created and applied from new schema changes:
migrations/
└─ 20210531022200_add/
└─ migration.sql
Your database is now in sync with your schema.
✔ Generated Prisma Client (2.23.0) to ./node_modules/@prisma/client in 59ms
I never encountered migrate asking to reset the database. I think there’s a conflict on your database structure with your migrations, hence it asks you to reset it to resolve it.
can you try prisma migrate reset --force --preview-feature ? it clears the DB and applies all migrations, then try normal migrate see if still asks you to reset it. Doing reset also seeds data if you have one.Keanu Gargar
05/31/2021, 2:30 AMKeanu Gargar
05/31/2021, 2:30 AMIn general, you should not edit or delete a migration that has already been applied. Doing so can lead to inconsistencies between development and production environment migration histories, which may have unforeseen consequences - even if the change does not appear to break anything at first.and then
Keanu Gargar
05/31/2021, 2:30 AMRun- Prisma Migrate detects that a migration has changed, and asks toprisma migrate devthe database:reset
Keanu Gargar
05/31/2021, 2:31 AMJames
05/31/2021, 2:32 AMKeanu Gargar
05/31/2021, 2:35 AMprisma migrate deploy , this is more suited for production though as it says on doc.Beyond
05/31/2021, 4:53 AMJames
06/01/2021, 12:46 AMEddy Nguyen
06/01/2021, 2:45 AMJames
06/21/2021, 9:17 PM