Handling existing migrations and schema on new another app.
Unanswered
Red wood ant posted this in #help-forum
Red wood antOP
Let’s say that I have a series of migrations and a final schema (using Prisma) on an application that is doing CRUD on that schema and everything works as expected. Now if I was to start a NEW application that’s actually going to make use of the database using the SAME schema , do I need to copy over not only the schema file but all the migration folders and SQL files generated during the development of the CRUD application or can I just copy the schema only then run the prisma generate command? And what’s the best practice in terms of keeping the schema in sync if I happen to make schema changes to the CRUD application as I continue to iterate the schema changes? Do I need to run the same commands on the NEW application or can I wait until I’ve reached a certain point and then copy over the changes that I’ve made on the CRUD application and just do a single migrate command to sync up the changes? Call me perplexed.
1 Reply
@Red wood ant Let’s say that I have a series of migrations and a final schema (using Prisma) on an application that is doing CRUD on that schema and everything works as expected. Now if I was to start a NEW application that’s actually going to make use of the database using the SAME schema , do I need to copy over not only the schema file but all the migration folders and SQL files generated during the development of the CRUD application or can I just copy the schema only then run the prisma generate command? And what’s the best practice in terms of keeping the schema in sync if I happen to make schema changes to the CRUD application as I continue to iterate the schema changes? Do I need to run the same commands on the NEW application or can I wait until I’ve reached a certain point and then copy over the changes that I’ve made on the CRUD application and just do a single migrate command to sync up the changes? Call me perplexed.
Red wood antOP
Okay, I think I found the answer. Thank you, AI! Haha. So the short answer is: DO NOT copy migration files. Do this instead: 1 - Copy the schema.prisma file ONLY. 2 - Run prisma db pull to sync with existing database. 3 - Run prisma generate to create the client on NEW application.