Github integration issue -> Remote migration versions not found in local migrations directory.
Hello. Sorry in advance as I am not very knowledgeable when it comes to webdev. I have a project made by someone else so I am not entirely sure where to start.
We have set up a website with supabase and vercel, and it works fine, but I'm trying to add vercel and github integration to my supabase account because I figured it would simply be easier to manage that way.
But I am having an issue where when I push to git it simply fails the supabase preview check on github saying "Remote migration versions not found in local migrations directory.". The vercel check succeeds and the website updates regardless though.
If anyone can help me resolve this or at least point me in the right direction in the docs or something I would appreciate it.
I don't know what other information is relevant in this case, let me know and I'll see what I find.
36 Replies
Just to confirm, you added the github integration yourself and did you follow the instructions here https://supabase.com/docs/guides/deployment/branching/github-integration. I ask because i'm wondering if previously you were using the UI to manage your database and so your local database is completely our of sync with the remote one hence this mismatch in migration versions?
Yeah I added it myself and no I didn't follow this. I'll take a look at it thank you. I also didn't have a supabase folder in my repo, which I don't know if it matters or not for this. Just trying to reverse engineer a bit here. Maybe I should just make a new project and figure that out a bit first.
what does your repo look like?

it does look like you have a supabase folder or did you add that now?
i added it now yeah
been trying to figure out how to set this up
oh okay, yeah i would go through that guide then and see what happens. My best guess is that you need to tell github which folder it should use for supabase and then you have to pull your remote db schema down and then that should get you closer
Thanks I'll see how it goes
I'm at the supabase db pull step right now, but I am running into this error

Any idea how I can sync the migration history to my local?
without accidentally overwriting the history in my supabase dashboard 😬
try this, delete the (local) migrations folder and run supabase db pull
i'm trying to make sure we only work on the local supabase instance and avoid touching the remote completely
It gives me the same error
what do you get if you type npx supabase migration list

did fetch
CLI Reference | Supabase Docs
CLI reference for the Supabase CLI
it seems like in your situation when you have migrations in remote and not in local what you have to do is apply supabase migration repair <migration-tag> --status reverted
for each of the remote migrations and then do supabase db pull
after fetching i have this

but i also manually removed one that was added by supabase which i assume is bad
20240101000003_enable_public_products.sql
where did you remove it from, locally?
yeah, just moved it out of the supabase folder that was generated when i did init and stuff earlier
supabase/migrations
but
it keeps complaining about this products relation which seems related to that file. does it when i do pull as well
which i am not sure if it's part of a larger issue

basically it seems like
actually idk
from this image and the one further up it seems like we shouldn't have that first file there?
was that a local change you did?
No that was just added there by supabase i think. All I did was supabase init, supabase start, and supabase db pull
that's why i removed it but i tried adding it back
but without it, there also seem to be an error one sec
i feel like this is just gonna be like pulling on a thread 😹
I just feel like these migrations are kinda busted?

i don't know exactly how this works but
i feel like these changes have already been applied to my supabase project
the first migration says add_download_url_to_user_purchases so that's where it is throwing
but further down there's remove_user_purchases_table so like
should i just remove these and remove them in remote?
like this is supposed to be history so idk why it's doing anything
what was the commend ran here?
supabase db pull
like am i understanding this right that this is kind of like supabase's versioning system? if so i should be able to just purge this and start clean right?
as far as i'm aware you can purge and start again, i've confused myself now so it might be worth running supabase start in a different terminal and taking a look at your local database
see what tables are/ are not there
Well just deleting and commiting after syncing them as we had done seems to have made it happy at least.

now we'll see if it can do the rest of the github integration steps
haha one step closer
Ok I think after doing supabase migration repair --status reverted on all the migrations in the history in my dashboard it seems to all work now.
I finished all of the steps on the github integration and its pushed to git and it has resolved successfully on both vercel and supabase
Thanks a lot for the help
awesome, glad to hear it!