Branches not working
i have 3 diffrent projects in supabase since creating a branch does not work i have staging, product how do i make so i can merge the dev with prod or such?
34 Replies
You don’t “merge” Supabase projects cause each project is an isolated postgres + services stack
The safe way to promote changes from dev - staging - prod is migration driven (or use new branching to avoid multiple projects)
This avoids having three separate projects
You create branches of your prod project, test there then merge to main (prod)
Thanks for the help i have been creating branches but the migration always fails
i have seen people use projects for staging/dev environments before and what they tend to do is link to each of those projects in turn and push/pull migration changes and edge functions to each environment from the cli. Link to dev project -> push changes -> link to pro -> push changes. Never done it myself but might be something you are looking to do if you want to ensure changes are reflected in each "stage"
Yeah thank you the core issue is the branching i am debugging it now and hoping to get branches to work today
i found the issue my local migration file is ariybd 200-300 files but the migrations on the prod is only 8-9 migrations but all the files that i have created and such are there all teh tables and such but the migrations are not there?
How can i sync or fix so the migrations i have localy go into the history online
you would have to repear the migration history table https://supabase.com/docs/reference/cli/supabase-migration-repair
CLI Reference | Supabase Docs
CLI reference for the Supabase CLI
Thank you, my issue is that the supabase in the cloud has the correct scheme and tables but wrong history and localy the migration history is correct
yeah you will need to repair the migrations and the link goes over how to do that. You will have to remove migration history either from remote or local to bring things back in line. This will not effect tables or current schema layout in remote
2025/09/21 13:30:17 INFO Pulling migrations from database... host=[2a05:d018:135e:1600:60c5:7d85:fbe3:ce3c]:5432
2025/09/21 13:30:18 INFO Pulling migrations from database... host=[2a05:d018:135e:1602:cc46:ffab:3556:cc67]:5432
2025/09/21 13:30:18 INFO Checking service health... project_ref=tthsfugiwdusjziavjru
2025/09/21 13:30:24 INFO realtime service not healthy: Failed to retrieve project's realtime service health retry_after=2.133s
2025/09/21 13:30:31 INFO realtime service not healthy: Failed to retrieve project's realtime service health retry_after=3.349s
2025/09/21 13:30:39 INFO realtime service not healthy: Failed to retrieve project's realtime service health retry_after=8.732s
2025/09/21 13:30:53 INFO realtime service not healthy: Failed to retrieve project's realtime service health retry_after=14.792s
2025/09/21 13:31:13 INFO realtime service not healthy: Failed to retrieve project's realtime service health retry_after=18.515s
2025/09/21 13:31:34 INFO Config file not found... path=supabase/config.toml
2025/09/21 13:31:36 INFO Connecting to database... host=[2a05:d018:135e:1602:cc46:ffab:3556:cc67]:5432
Applying migration 20241220000000_mitra_integration.sql...
Applying migration 20250115000001_add_mitra_identifier_fields.sql...
2025/09/21 13:31:39 ERROR: relation "public.tires" does not exist (SQLSTATE 42P01)
At statement: 0
-- Add Mítra integration identifier fields to tires table
-- These fields are needed for the Mítra ERP integration
-- Add external_id field (Mítra's product_id UUID)
ALTER TABLE public.tires
ADD COLUMN IF NOT EXISTS external_id TEXT
I am consitantly running into these kinds of errors is this just a timestamp issue
can you go into your dashboard project and click the project status
are you getting errors?

these errors with migration look like migration files that are out of sync
can you run
supabase migration list on the clino error in the web i am on a sanbdox since i dont wana mess up production
I have made significant progress the historyis getting better
yeah you won't be able to run supabase db pull with that migration history on local or remote
if you don't need you local migration files what i might suggest is save them in git history and then run
supabase migration fetch to replace the local migration file with the remote
and see if that helpsThe history is getting better i am trying to fix it to create a branch
if you remote database is working as it should i would just replace the local migration files with the remote?
the remote migration is not working it has 8 migration files but the database is wayy bigger then that
its 113 tables
the remote list you've shown here looks more than 8?
ahh but that is the sandbox
yeah lol and i need so the sandbox one when i create a branch it creates a branch correctly without a mgiration error
Version Name Inserted at (UTC)
20250612141845 migration 12 Jun 2025, 14:18:45
View migration SQL 20250115000010 add_address_fields_to_profiles 15 Jan 2025, 00:00:10
View migration SQL 20250115000009 fix_rating_null_constraint 15 Jan 2025, 00:00:09
View migration SQL 20250115000008 fix_single_upsert_function 15 Jan 2025, 00:00:08
View migration SQL 20250115000007 create_simple_bulk_function 15 Jan 2025, 00:00:07
View migration SQL 20250115000006 user_specific_tire_verifications 15 Jan 2025, 00:00:06
View migration SQL 20250115000005 create_function_monitoring_tables_safe 15 Jan 2025, 00:00:05
View migration SQL 20250115000004 create_function_monitoring_tables 15 Jan 2025, 00:00:04
View migration SQL 20250115000003 create_metrics_collection 15 Jan 2025, 00:00:03
View migration SQL 20250115000002 create_instant_alerts 15 Jan 2025, 00:00:02
View migration SQL 20250115000001 add_mitra_identifier_fields 15 Jan 2025, 00:00:01
View migration SQL 20250115000000 add_resend_fields_to_newsletter_subscriptions 15 Jan 2025, 00:00:00
View migration SQL 20241220000000 mitra_integration 20 Dec 2024, 00:00:00
View migration SQL this is the prod one thats all the migration things
20250612141845 migration 12 Jun 2025, 14:18:45
View migration SQL 20250115000010 add_address_fields_to_profiles 15 Jan 2025, 00:00:10
View migration SQL 20250115000009 fix_rating_null_constraint 15 Jan 2025, 00:00:09
View migration SQL 20250115000008 fix_single_upsert_function 15 Jan 2025, 00:00:08
View migration SQL 20250115000007 create_simple_bulk_function 15 Jan 2025, 00:00:07
View migration SQL 20250115000006 user_specific_tire_verifications 15 Jan 2025, 00:00:06
View migration SQL 20250115000005 create_function_monitoring_tables_safe 15 Jan 2025, 00:00:05
View migration SQL 20250115000004 create_function_monitoring_tables 15 Jan 2025, 00:00:04
View migration SQL 20250115000003 create_metrics_collection 15 Jan 2025, 00:00:03
View migration SQL 20250115000002 create_instant_alerts 15 Jan 2025, 00:00:02
View migration SQL 20250115000001 add_mitra_identifier_fields 15 Jan 2025, 00:00:01
View migration SQL 20250115000000 add_resend_fields_to_newsletter_subscriptions 15 Jan 2025, 00:00:00
View migration SQL 20241220000000 mitra_integration 20 Dec 2024, 00:00:00
View migration SQL this is the prod one thats all the migration things
113 tables or migration files, 113 tables seems quite big for an application?
its a marketplace with a booking system and payment ik its very big lol
this is the prod one lol

alot of stuff there
Ahh right, yeah the only thing i can say for now is you will have to get the migration history in order first
yup im trying lol
its just creating a branch and then from that fix the error and try to create it again
current status

yeah let me know how you get on, any insight you get fixing so may migration issues would be helpful for myself and other
almost finished
the things are failing again and again i have just had cursor create it basicly from scratch
its increadiblty tedious since it crashes and stops after each errror so if there are 10 errors i always need to rebuild it and then wait 5 minutes then fix the next error
@ihm40 is there no quiker waay to diagnose issues then rebuilding every time
is there no better way to do this since supabase gives me the errors so it knows what is correct can i not export it or the current migration of the system
ok i figured it out
what did you do if you don't mind me asking
I copied the entire scheme then used the mcp server with cursor to painstakingly copy everything from remote then. i create migratsion files agian from there i then run on a local db to see if everything is up do date and working from there i then go and make a branch and debug that and after that its fixed
but since supabase knows what it is and how it should be i dont understand how there is not a download all or something for the migrations for things like that when this happens
would have saved me 10 hours
download all migrations? tha is what
supabase db fetch is for i believeThe the migration folder was empty
Also that cmd does not work
sorry
supabase migration fetchdoe s not work again i dont have migration files
