My supabase remote and local migrations are completely off
I started working on a project and I was trying to set up supabase locally so I can test the Edge functions before deploying. I noticed a couple of things in the migrations:
1. The first is that the first 2 migrations have their names like this:
20250720115329-90dac62d-9998-4e64-83a4-57d5a1a9c289.sql
& 20250722182953-4e8ca653-37f4-494b-a494-ccda73a1c58d.sql
. You can see that there is a - here instead of a _ after the timestamp which causes issues when I run the command supabase start
as these migrations are not applied.
2. Secondly, none of the migrations in local and remote are matching after I run supabse migration list
. They are completely off. The remote migrations do not exist in local and the local migrations do not exist in remote. I don't know how this could have happened (this was a lovable made proejct handed over to me to work on) but I am trying to understand how I can fix it. Is there a way I can just get all the remote migrations in my migrations folder?48 Replies
see if this helps https://supabase.com/docs/reference/cli/supabase-migration-repair
CLI Reference | Supabase Docs
CLI reference for the Supabase CLI
For the record, this is how my migration list looks @ihm40
yeah my guess is if remote database looks okay then you might want to just delete local migration files and do
db pull
to baseline the schema to remote againSo delete all the files in the migrations folder and then run that command?
check them into git first to revert if it goes wrong but yeah that should work for you, you will get *remote_schema.sql file
in local migrations but from then on you can keep things in sync
truncated but I see this
^ that's the output of
db pull
oh sorry i didn;t see the full list
yeah they are very out of line
Yeah
34 in total
Not sure what happened here or how tbh. This was a lovable project someone handed off to me
I am guessing lovable did some weird stuff here
yeah these services tend to not handle migrations very well
i've seen this a fair few times
how can I fix this? Trying to get them to be in sync so I can set up supabase local and run edge functions
i think that any file in local that does not exist in remote has to be deleted and any migration not in local that is remote has to be reverted which is what i would do then run
db pull
I would say get confirmation from somewhere else though because i haven't fixed a migration issue that off before
and messing with remote is riskythere is no live data on this project yet
ideally i just want that the functioning state of this is up and synced
yeah give my suggestion a go then and let me know if it works but i can't see any other way to get everything back in line
worst case you delete all migrations in local and all migrations in remote
and baseline using
supabase db pull
I have a total of 30+ reverts to run but I think I am getting network restricted after a couple. Is there a way to bypass this? I can't manually remove the network restriction from the UI cause it says I need additional permissions.
I have to wait 30 minutes for it to reset
I haven't come across this issue before, what does the error look like?
yeah this seems like something you have to be given permissions for
if you're doing work on behalf of someone else
I can run these migrations but then after a few commands I get network restricted
Then have to wait 30 mins for it to be removed
where are you running these from, the cli?
Yes the cli
I finally got through all the migration reverts. No issues. As soon as I ran
db pull
I see this:
and got network restricted again lol
cue the 30 min timer
Okay so now the migrations in remote are deleted after running the revert commands. What are the next steps here for me?what does migration list look like now
Nothing in remote and 58 local
you would need to get rid of local migration files also (after backing them up somewhere) and then run
supabase db pull
Now running the db pull and on one image, it says:
i think you need the db password for db pull
did it ask you for it?
I have supabase linked
i'm also not sure why it was downloading images at all
and no it's not asking me for it
it's downloading a bunch of images off of docker and all work fine except for this one
this suggests to me that supabase might not be fully installed
have you got
supabase start
working beforeno not before. i tried to but because of the issues with schema diffs
It never started
also I've got this now

at least we're in sync now lol

if this is your remote migrations for supabase then i suspect this i think this is expected. it should add the schema
yeah so you shoudl have a migration file in the
migrations
folderokay so I should run supabase start now?
which is the remote schema dump
yean run it because it should have worked even without getting migrations in line
it doesn't need to talk to remote as it is a local supabase
got it
getting this error
Yeah i got this earlier with supabase and judging by this xhttps://github.com/supabase/cli/issues/4215 i think it is a bug with the newer version of the cli
GitHub
Unable to start local supabase via cli | Issue in `supabase_storage...
Describe the bug Unable to start local setup, I just initialised this in nextjs and it failed to launch local supabase using supabase start command. To Reproduce Steps to reproduce the behavior: Up...
oh
can we downgrade to lower version
were you able to fix it
i haven't given it a shot yet but i think
supbase@<version> start
let's you downgrade
by the way i'm signing off now as it's getting late where i am, i'll reply to any message tomorrow though hopefullyOh for sure. Thank you a lot
no worries
just ping me with any other questoins using @ so i see it
@ihm40 hey so I saw that the new version 2.47.2 came out of the CLI. Installed it and still nothing:
Is there a specific version I can roll back to? I installed via brew btw
i'm not too sure what this error is
Rolling back to 2.40.7 now saw in a github thread that that worked
but no matter what I do so far supabase start just doesn't seem to work
maybe do stop all first before running start
it worked finally
š

nice!