Replace main branch with everything in development but storage
Hi!
Quick question, how can I replace everything in my main branch including all tables & schemas with everything in my development branch without replacing the files in the main storage branch?
101 Replies
If you have made changes to your development branch then the migration files for that branch (or changes if done in the UI) should just reflect that you are deleting tables/schemas and adding new tables/schemas
When you merge that dev branch it should reflect those changes
I mean, I don't really see anything

In the development branch?
click view logs as you have some issues
These are the issues, not sure how to resolve them.
Haven't really used migration files as I thought I could handle it all through Supabase UI, I guess I'm mistaken. However, earlier even when there weren't any issues I still wasn't able to push changes

are you connected to github in supabase?
Yeah
how did you create this development branch, normally it asks you to provide a branch to point to

I wish I could tell you, it's been months.
I had two branches, main & staging. I realized today that I probably should create a development branch in my github to match the one in my supabase, I thought it'd automatically configure from there

And, if your curious to why the deploy to production section is off;

I can't seem to enable it without this error
So the first thing to check, is the supabase directory in the root like github is saying i.e you have
supabase/
located there?Yes
along with
supabase/migrations
also, yes
Are those migration files in line with your main/prod database because i think that is how branches are created when using github
It's a long story, but no.
This is entirely a new repo, main is just a spin off of my new codebase.
I had to use --repair or something to have it ignore it
actually
i backtrack
I did use supabase db pull to pull my old codebase into the migration files for the main branch
so yes?
could you go in the cli and just run
supabase migration list
just to confirm
I think the more recent migration is because I did a supabase db diff between the main migration and my new codebase
if you need that local migration then you should probably push it up to remote otherwise i would remove it
okay, i'll remove it. I have everything saved
then check to make sure your github branch is all up to date with the local migration files
both branches each have their respective local migration file
Right that might be more complicated, how do the migrations of main branch differ from dev branch
the development branch migration file is my new updated supabase while dev is the old supabase's migration file
do you mean main instead of dev?
yeah sorry
could you switch branches to main and run
supabase migration list
what I showed you was the main
what about dev
I have no clue what the other two are?

In my github, this is all I have under the migrations folder

i think this is what is causing the error "remote migration versions not found in local migrations directory"
So what should I do?
let's try removing the local migration files (after saving them somewhere else) then running
supabase db fetch
In which, the development branch?
yeah the dev branch, the one with the mismatched images above because remote file looks the same for main and dev so you don't want to touch that but instead baseline it
I can't seem to run
supabase db fetch

sorry might be
supabase migration fetch
Should I provide the db url to the development branch?
it doesn't work like that which is can be confusing
but just use the your main branch
or your main project rather
Running that creates a migration file that has all of my old supabase stuff, if that's right then seems to be good so far
run
supabase migration list
now
okay i think that if you were to commit those migration file changes now, your dev branch on supabase would hopefully be aligned with your main branch, then you can create additional changes on top of that
if I commit that, it'll wipe all of my new changes
Just to give you an idea, this is the main branch publci schema for example

this is my development branch public schema

the migration file we just created contains everything from the main schema, and if I push it it'll overwrite everything from the development schema to my old code which I don't want
am I mistaken?
which file contains your migration changes from the local files on dev you just removed, i assume it was the most recent one, the one ending in 408
its that one
okay add that back in in local migrations on dev branch
run
supabase migration list
is it possible to just do supabase db diff? I noticed so many issues with just like code and it kept on going
it was just bs like this:

what would you run db diff against?
well, while I was struggling earlier and had no response I had AI come up with this:
supabase db diff \
--db-url "postgresql://postgres.vutvswqnzyfh...:...@aws-0-us-west-1.pooler.supabase.com:5432/postgres?sslmode=require" -f dev_to_main
Which basically just gave me a updated difference between my old and new code
which database is this pointing to, the dev one with your most recent changes?
yea
okay yeah try running that and see what file it produces
alright, seems to produce everything right
what does
supabase migration list
look like
okay that looks good, now if you commit those file changes and push your code to gitub (not db push) it should hopefully pick it up
and generate the tables
hm... wait.i just noticed, Im not seeing all of my tables when I do like a search for "CREATE ..."
i do notice a lot of alter tables, just to confirm, is it possible that it has no reason in creating new tables since It shared the names with both the old and new supabase?
yeah i would imagine that might be the case, not certain, but that would make sense
alright cool
and just to be sure, this is all under the development branch
is that where i should push it?
yeah all under dev, push code to github.
okay pushed
hopefully the supabase bot right about now should be updating the preview branch, see if the ui has updated to give new logs
hmm, I might have to create a new branch
for some reason I think i might've linked development (supabase branch) to the main branch (github) hence it's not picking up changes
again, I did this months ago so I can't exactly remember which I linked which to
wait actually, might be in staging
ahh okay, yeah i would not remove the old branch as it might have changes still but create a seperate branch to see if it picks up change for dev
okay, lets see...
while we wait, i appreciate you man
okay, this is new:

haven't seen this

this was like some of the issues I said earlier
Okay looks to be slightly better
good news to hear
GitHub
ERROR: schema "supabase_functions" does not exist · Issue #1552 ·...
Describe the bug I run supabase db push locally and get this error ERROR: schema "supabase_functions" does not exist (SQLSTATE 3F000) To Reproduce Steps to reproduce the behavior: Create ...
apparently you need to enable supabase webhooks
that'd make sense, on my dev branch (supabase) I make use of webhooks and on the main branch i dont
wait nvm
i guess its already enabled

is there a proper way to enable them?
or
it could be pg_net
oh, nvm looks like its already eanbled too
try this comment feedback https://github.com/orgs/supabase/discussions/18937#discussioncomment-12304278
GitHub
Branching - Early access | Feedback discussion · supabase · Discu...
This discussion is for tracking feedback and possible issues for Supabase Branching. This will help us plan a roadmap for the feature going forward. Vote for hosting provider integrations here and ...
okay
i'll go ahead and push that
yeah see if that works, btw i'm assuming this is blocking all tables from being generated?
yeah, I don't seen to see any changes
okay, so

the error is gone
now It's this, which was what I was dealing with earlier
Ahh okay, so i would check your schema file and see if your MessageType enum is being defined before you use it
yeah it was, i moved it and now i'm just waiting
but there were like so many errors after I got this fixed, and I don't understand why they'd happen
i expect all subsequent issues might just be manually fiddling with SQL, btw i have to sign off in a few mins but will be back around later in the evening so feel free to @ me and i should see it
okay, fair. really appreciate you, and just to confirm after I hopefully get these errors fixed, what would be the next steps?
after that you should see that your dev branch has all of your changes and that the schema migrations file are aligned, If everything looks good, merging that branch should apply migration file changes to prod.
but first i would get to a stage where your branch is not throwing off errors and looks correct.
okay, i'll do that then
and just to confirm since we just added to new branch in supabase dev, once I have everything working can I get it switched back development?
switched back in what way?
instead of having dev, could I just have it be development?
