Safe to delete migration files?

Apologies if this is kind of a beginner question, but I'd like to know if it's safe to delete my migration SQL files purely for cleanup/organization purposes? What about the snapshot.json files? Thank you!
2 Replies
deadlinecode
deadlinecode•12mo ago
If you are developing and you don't have the migration files on prod or somewhere where they are actually needed you can just delete them Drizzle will create new ones on the next drizzle-kit generate But if you actually have migration files that are on prod and users are using them / you are using them via the migrate function you should keep them because they tell drizzle how to migrate the already existing data to the new schema If you are developing and you run drizzle-kit generate a couple of times you can delete the sql files that are new to the drizzle folder and generate on last time bevore putting the app on prod so that drizzle generates only one sql file that migrates the data Hope that helps For the snapshot.json files you will have to wait for somebody else to answer 😅
terryball
terryballOP•12mo ago
Thank you @deadlinecode that's very helpful. Good tip on generating one final migration after developing - I have lots of quick reversions/edits in my migration history which adds to the bloat. Besides general cleanup / organization, I'm also noticing that my drizzle-kit operations and migrations are taking much longer, which I imagine is due in part to the fact that I have hundreds of migration files. I'd love to be able to consolidate them into just 1 or 2 files, but I'm not sure of the implications of deleting the migration files and then re-running drizzle-kit generate
Want results from more Discord servers?
Add your server