next.jsneondrizzle-orm

drizzle ORM db generate reset


There is a problem that in migration i have accidentally deleted the base file and whenever I run generate command it will make file that have command applies changes to main file(in which I need the base sql file for it). I was hoping if there is any way to reset my sql db from 0 again right now i only have file 06 and deleted 01 - 05. I want to know how to reset generate drizzle. from 0 again. please tell me a way to reset generate of drizzle to start from base again

enter image description here

enter image description here


Solution

  • First and foremost you should backup any existing data. (If you can't run the risk of losing it) Instructions can be found here.

    To make this as easy as possible you should delete any existing records and tables beforehand.

    To reset the state of drizzle you'd need to delete the meta folder at /migrations/meta alongside every pending migration you have i.e 006_bouncy_young_avengers.sql.
    You would then run the normal workflow with e.g npx drizzle-kit generate to generate the migration and npx drizzle-kit migrate to migrate it.