S
Supabase•5d ago
aith

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
aith
aithOP•5d ago
For the record, this is how my migration list looks @ihm40
ihm40
ihm40•5d ago
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 again
aith
aithOP•5d ago
So delete all the files in the migrations folder and then run that command?
ihm40
ihm40•5d ago
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
aith
aithOP•5d ago
The remote database's migration history does not match local files in supabase/migrations directory.

Make sure your local git repo is up-to-date. If the error persists, try repairing the migration history table:
supabase migration repair --status reverted 20250907022308
supabase migration repair --status reverted 20250907102256
supabase migration repair --status reverted 20250912073048
supabase migration repair --status reverted 20250912073226
supabase migration repair --status reverted 20250912074200
supabase migration repair --status reverted 20250916051730
supabase migration repair --status reverted 20250920063327
supabase migration repair --status reverted 20250920063601
supabase migration repair --status reverted 20250920063849
supabase migration repair --status reverted 20250921063715
supabase migration repair --status reverted 20250921103806
supabase migration repair --status reverted 20250921120842
supabase migration repair --status reverted 20250921122437
supabase migration repair --status reverted 20250921122550
supabase migration repair --status reverted 20250921123335
supabase migration repair --status reverted 20250921124126
The remote database's migration history does not match local files in supabase/migrations directory.

Make sure your local git repo is up-to-date. If the error persists, try repairing the migration history table:
supabase migration repair --status reverted 20250907022308
supabase migration repair --status reverted 20250907102256
supabase migration repair --status reverted 20250912073048
supabase migration repair --status reverted 20250912073226
supabase migration repair --status reverted 20250912074200
supabase migration repair --status reverted 20250916051730
supabase migration repair --status reverted 20250920063327
supabase migration repair --status reverted 20250920063601
supabase migration repair --status reverted 20250920063849
supabase migration repair --status reverted 20250921063715
supabase migration repair --status reverted 20250921103806
supabase migration repair --status reverted 20250921120842
supabase migration repair --status reverted 20250921122437
supabase migration repair --status reverted 20250921122550
supabase migration repair --status reverted 20250921123335
supabase migration repair --status reverted 20250921124126
truncated but I see this ^ that's the output of db pull
ihm40
ihm40•5d ago
oh sorry i didn;t see the full list yeah they are very out of line
aith
aithOP•5d ago
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
ihm40
ihm40•5d ago
yeah these services tend to not handle migrations very well i've seen this a fair few times
aith
aithOP•5d ago
how can I fix this? Trying to get them to be in sync so I can set up supabase local and run edge functions
ihm40
ihm40•5d ago
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 risky
aith
aithOP•5d ago
there is no live data on this project yet ideally i just want that the functioning state of this is up and synced
ihm40
ihm40•5d ago
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
aith
aithOP•5d ago
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
ihm40
ihm40•5d ago
I haven't come across this issue before, what does the error look like?
aith
aithOP•5d ago
unexpected unban status 403: {"message":"Your account does not have the necessary privileges to access this endpoint. For more details, refer to our documentation https://supabase.com/docs/guides/platform/access-control"}
unexpected unban status 403: {"message":"Your account does not have the necessary privileges to access this endpoint. For more details, refer to our documentation https://supabase.com/docs/guides/platform/access-control"}
ihm40
ihm40•5d ago
yeah this seems like something you have to be given permissions for if you're doing work on behalf of someone else
aith
aithOP•5d ago
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
ihm40
ihm40•5d ago
where are you running these from, the cli?
aith
aithOP•5d ago
Yes the cli I finally got through all the migration reverts. No issues. As soon as I ran db pull I see this:
Initialising login role...
Connecting to remote database...
The remote database's migration history does not match local files in supabase/migrations directory.

Make sure your local git repo is up-to-date. If the error persists, try repairing the migration history table:
supabase migration repair --status reverted 20250922093113
Initialising login role...
Connecting to remote database...
The remote database's migration history does not match local files in supabase/migrations directory.

Make sure your local git repo is up-to-date. If the error persists, try repairing the migration history table:
supabase migration repair --status reverted 20250922093113
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?
ihm40
ihm40•5d ago
what does migration list look like now
aith
aithOP•5d ago
Nothing in remote and 58 local
ihm40
ihm40•5d ago
you would need to get rid of local migration files also (after backing them up somewhere) and then run supabase db pull
aith
aithOP•5d ago
Now running the db pull and on one image, it says:
Status: Downloaded newer image for public.ecr.aws/supabase/edge-runtime:v1.69.12
error diffing schema: error running container: exit 1:
[select_097e65a]: Executing query failed: :invalid_password
main worker has been destroyed
Status: Downloaded newer image for public.ecr.aws/supabase/edge-runtime:v1.69.12
error diffing schema: error running container: exit 1:
[select_097e65a]: Executing query failed: :invalid_password
main worker has been destroyed
ihm40
ihm40•5d ago
i think you need the db password for db pull did it ask you for it?
aith
aithOP•5d ago
I have supabase linked
ihm40
ihm40•5d ago
i'm also not sure why it was downloading images at all
aith
aithOP•5d ago
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
ihm40
ihm40•5d ago
this suggests to me that supabase might not be fully installed have you got supabase start working before
aith
aithOP•5d ago
no not before. i tried to but because of the issues with schema diffs It never started
aith
aithOP•5d ago
also I've got this now
No description
aith
aithOP•5d ago
at least we're in sync now lol
No description
ihm40
ihm40•5d ago
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 folder
aith
aithOP•5d ago
okay so I should run supabase start now?
ihm40
ihm40•5d ago
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
aith
aithOP•5d ago
got it
{"level":50,"time":"2025-09-28T18:59:20.705Z","pid":1,"hostname":"d7aba848c0fe","region":"not-specified","type":"startupError","error":{"raw":"{\"metadata\":{},\"code\":\"InternalError\",\"httpStatusCode\":500,\"userStatusCode\":500}","name":"Error","message":"Migration fix-object-level not found","stack":"Error: Migration fix-object-level not found\n at Object.InternalError (/app/dist/internal/errors/codes.js:235:34)\n at /app/dist/internal/database/migrations/migrate.js:425:36\n at async /app/dist/internal/database/migrations/migrate.js:553:14\n at async connectAndMigrate (/app/dist/internal/database/migrations/migrate.js:383:5)\n at async runMigrationsOnTenant (/app/dist/internal/database/migrations/migrate.js:273:3)\n at async main (/app/dist/start/server.js:58:5)","statusCode":500},"msg":"Server not started with error"}
{"level":50,"time":"2025-09-28T18:59:20.705Z","pid":1,"hostname":"d7aba848c0fe","region":"not-specified","type":"startupError","error":{"raw":"{\"metadata\":{},\"code\":\"InternalError\",\"httpStatusCode\":500,\"userStatusCode\":500}","name":"Error","message":"Migration fix-object-level not found","stack":"Error: Migration fix-object-level not found\n at Object.InternalError (/app/dist/internal/errors/codes.js:235:34)\n at /app/dist/internal/database/migrations/migrate.js:425:36\n at async /app/dist/internal/database/migrations/migrate.js:553:14\n at async connectAndMigrate (/app/dist/internal/database/migrations/migrate.js:383:5)\n at async runMigrationsOnTenant (/app/dist/internal/database/migrations/migrate.js:273:3)\n at async main (/app/dist/start/server.js:58:5)","statusCode":500},"msg":"Server not started with error"}
getting this error
ihm40
ihm40•5d ago
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...
aith
aithOP•5d ago
oh can we downgrade to lower version were you able to fix it
ihm40
ihm40•5d ago
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 hopefully
aith
aithOP•5d ago
Oh for sure. Thank you a lot
ihm40
ihm40•5d ago
no worries just ping me with any other questoins using @ so i see it
aith
aithOP•4d ago
@ihm40 hey so I saw that the new version 2.47.2 came out of the CLI. Installed it and still nothing:
failed to display json stream: error pulling image configuration: download failed after attempts=6: dialing d2glxqk2uabbnd.cloudfront.net:443 container via direct connection because disabled has no HTTPS proxy: connecting to d2glxqk2uabbnd.cloudfront.net:443: dial tcp [2600:9000:2543:c200:1d:242c:6e40:21]:443: connect: no route to host
failed to display json stream: error pulling image configuration: download failed after attempts=6: dialing d2glxqk2uabbnd.cloudfront.net:443 container via direct connection because disabled has no HTTPS proxy: connecting to d2glxqk2uabbnd.cloudfront.net:443: dial tcp [2600:9000:2543:c200:1d:242c:6e40:21]:443: connect: no route to host
Is there a specific version I can roll back to? I installed via brew btw
ihm40
ihm40•4d ago
i'm not too sure what this error is
aith
aithOP•4d ago
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
ihm40
ihm40•4d ago
maybe do stop all first before running start
aith
aithOP•4d ago
it worked finally šŸ™
aith
aithOP•4d ago
No description
ihm40
ihm40•4d ago
nice!

Did you find this page helpful?