im trying to setup prisma migrate on a database (mysql) already populated with data on my dev enviroment but so far i can't make it work.
1.
I did prisma db pull to create the schema from it (works fine).
When running prisma migrate dev --name initial-migration --create-only i get a warning asking to RESET the database... i dont want that. So...
2.
Run this command prisma migrate diff --from-empty --to-schema-datamodel prisma/schema.prisma --script > migration.sql and manually move the sql file to a manually created prisma/migrations/init folder
3.
Now i try to baseline that migration running prisma migrate resolve --applied "initial"
i get an error saying the migration cant be found.. but it's there and even prisma knows it.,..
console capture of the error
You could achieve what you want by following these steps
mysqldump --user=root --password="" database_name > database_name.sqlnpx prisma db pullnpx prisma migrate dev --name your_migration_namemysql --user=your_username --password=your_passwordmysql[(none)]>>use database_namemysql[database_name]>> source C:\path\to\your\database_backupfile\database_name.sql
You should get everything in your database in sync with prisma and get your data back as well.If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With