VicenMC
PPrisma
•Created by VicenMC on 9/18/2024 in #help-and-questions
Issue with migrations
Hi! I've been trying to apply a change to my schema but been facing some errors and im not sure what im doing wrong, do you think you can help me please?
I tried to add a new table to my prisma schema, but every time i try to apply the migration with npx prisma migrate dev --name sample_name i get a message saying that a foreign key on one of the tables i had already on the schema was removed and then added again. Im not sure where this change comes from or if it could be a bug. That same message asks me to restart my database and that all data will be lost.
I dont want my data to be lost, so i tried to do a baselining. As the documentation states y moved my migration folder and followed the steps, when i tried to do the migration again i got an error saying that all of the migration folders were missing on my folder, so i restored it.
I also used npx prisma migrate status to check if any migration was still not applied, but all i got is that the schema was up to date.
Then i tried doing an npx prisma migrate deploy, as i understood that this would apply all the pending migrations and sync database - schema.
The command ran okay, but when i repeat the process of db pull -> prisma generate -> prisma migrate dev i get the same changes on my foreign keys and the alert that all data will be lost.
Am i missing some step or am i doing something wrong? Even with the original prisma.schema thats generated with the npx prisma db pull command i keep getting the same message when doing an migration. I dont want to lose my database info and i would like to be able to apply changes to the schema in the future.
Thank you for your help!
2 replies
PPrisma
•Created by VicenMC on 9/13/2024 in #help-and-questions
Using the same schema on different projects
Hello!
I have different projects that use the same prisma.schema. Every time i change something on my schema i have to update the file on all of the other projects.
I wanted to ask if there's a way to sync them so all of my projects can point to a single schema and every time i wanna make a change i only have to worry for a single file.
I've read that creating an npm package and share it to all of the projects could be one solution. Just wanted to ask out of curiosity if someone knew any other option or possible solution for this situation to evaluate which one would be better for me to apply.
Thanks for your help!
4 replies