Baselining Migrations -- Local
Hey Supabase community , I'm having some difficulties creating a baseline migration for my databse. i'm developing locally with supabase running in docker. so far , i've been making direct supabase edits via postgres to update and evolve my data model and schema. i want to reset my migration history and i thought it would have been as easy as dumping the complete schema after my direct edits and then using that as the baseline migration file...but i tried that and ran into migration errors becasue the complete dump also dumped all the schema outside of 'public' that i don't control like the 'auth' schema , 'storage', 'Realtime' and others. So i thought, maybe if i dumped just the public schema, then that would work as a baseline mgiraiton file. But running that ALSO failed regarding all the extensions that i had enabled .......so at this point i was really freaking out because i had ran "npx supabase reset" all my data and progress WIPED but migrations were failing. but thanfully i could restore the databse from the dumped schema file directly so that was a huge save. The direct restore simply restored the tables that didn't exist and skipped the ones that did and i didn't control.....
So the main questions is , now that my database is restored, how do i properly baseline my migration history ?
Secondly, what are best practices for using "npx supabase db reset" ?? is that command only suppoasded to be run at the start of a project? becaseu if i can't use a baseline migration file wiht extensionis, it means everytime i run "npx supabase db reset" all my extnesions are dropped and i would have to re-enable and reconifugre....is that command only suppsoed to be run at the start of a project? or is there a way to create complete baseline migration file so anytime i run that command, my database is restored to the most desired state.
PLEASE HELP! lol
1 Reply
Starting with the 2nd question, no
supabase db reset is not constricted to when you start a project you can kind of run it at any time you want to reset your database using just migration files as the reference point
what do you currently have inside of you migration folder and what command did you do to create that file?