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
ihm40
ihm404h ago
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
static
staticOP4h ago
I mean, I don't really see anything
static
staticOP4h ago
No description
ihm40
ihm404h ago
In the development branch? click view logs as you have some issues
static
staticOP4h ago
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
No description
ihm40
ihm404h ago
are you connected to github in supabase?
static
staticOP4h ago
Yeah
ihm40
ihm403h ago
how did you create this development branch, normally it asks you to provide a branch to point to
ihm40
ihm403h ago
No description
static
staticOP3h ago
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
No description
static
staticOP3h ago
And, if your curious to why the deploy to production section is off;
No description
static
staticOP3h ago
I can't seem to enable it without this error
ihm40
ihm403h ago
So the first thing to check, is the supabase directory in the root like github is saying i.e you have supabase/ located there?
static
staticOP3h ago
Yes
ihm40
ihm403h ago
along with supabase/migrations
static
staticOP3h ago
also, yes
ihm40
ihm403h ago
Are those migration files in line with your main/prod database because i think that is how branches are created when using github
static
staticOP3h ago
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?
ihm40
ihm403h ago
could you go in the cli and just run supabase migration list just to confirm
static
staticOP3h ago
No description
static
staticOP3h ago
I think the more recent migration is because I did a supabase db diff between the main migration and my new codebase
ihm40
ihm403h ago
if you need that local migration then you should probably push it up to remote otherwise i would remove it
static
staticOP3h ago
okay, i'll remove it. I have everything saved
ihm40
ihm403h ago
then check to make sure your github branch is all up to date with the local migration files
static
staticOP3h ago
both branches each have their respective local migration file
ihm40
ihm403h ago
Right that might be more complicated, how do the migrations of main branch differ from dev branch
static
staticOP3h ago
the development branch migration file is my new updated supabase while dev is the old supabase's migration file
ihm40
ihm403h ago
do you mean main instead of dev?
static
staticOP3h ago
yeah sorry
ihm40
ihm403h ago
could you switch branches to main and run supabase migration list
static
staticOP3h ago
what I showed you was the main
ihm40
ihm403h ago
what about dev
static
staticOP3h ago
I have no clue what the other two are?
static
staticOP3h ago
No description
static
staticOP3h ago
In my github, this is all I have under the migrations folder
No description
ihm40
ihm403h ago
i think this is what is causing the error "remote migration versions not found in local migrations directory"
static
staticOP3h ago
So what should I do?
ihm40
ihm403h ago
let's try removing the local migration files (after saving them somewhere else) then running supabase db fetch
static
staticOP3h ago
In which, the development branch?
ihm40
ihm403h ago
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
static
staticOP3h ago
I can't seem to run supabase db fetch
static
staticOP3h ago
No description
ihm40
ihm403h ago
sorry might be supabase migration fetch
static
staticOP3h ago
Should I provide the db url to the development branch?
ihm40
ihm403h ago
it doesn't work like that which is can be confusing but just use the your main branch or your main project rather
static
staticOP3h ago
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
ihm40
ihm403h ago
run supabase migration list now
static
staticOP3h ago
No description
ihm40
ihm403h ago
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
static
staticOP3h ago
if I commit that, it'll wipe all of my new changes
static
staticOP3h ago
Just to give you an idea, this is the main branch publci schema for example
No description
static
staticOP3h ago
this is my development branch public schema
No description
static
staticOP3h ago
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?
ihm40
ihm403h ago
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
static
staticOP3h ago
its that one
ihm40
ihm403h ago
okay add that back in in local migrations on dev branch run supabase migration list
static
staticOP3h ago
is it possible to just do supabase db diff? I noticed so many issues with just like code and it kept on going
static
staticOP3h ago
it was just bs like this:
No description
ihm40
ihm403h ago
what would you run db diff against?
static
staticOP3h ago
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
ihm40
ihm403h ago
which database is this pointing to, the dev one with your most recent changes?
static
staticOP3h ago
yea
ihm40
ihm403h ago
okay yeah try running that and see what file it produces
static
staticOP3h ago
alright, seems to produce everything right
ihm40
ihm403h ago
what does supabase migration list look like
static
staticOP3h ago
No description
ihm40
ihm403h ago
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
static
staticOP3h ago
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?
ihm40
ihm403h ago
yeah i would imagine that might be the case, not certain, but that would make sense
static
staticOP3h ago
alright cool and just to be sure, this is all under the development branch is that where i should push it?
ihm40
ihm403h ago
yeah all under dev, push code to github.
static
staticOP3h ago
okay pushed
ihm40
ihm403h ago
hopefully the supabase bot right about now should be updating the preview branch, see if the ui has updated to give new logs
static
staticOP3h ago
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
ihm40
ihm403h ago
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
static
staticOP3h ago
okay, lets see... while we wait, i appreciate you man
static
staticOP3h ago
okay, this is new:
No description
static
staticOP3h ago
haven't seen this
static
staticOP3h ago
No description
static
staticOP3h ago
this was like some of the issues I said earlier
ihm40
ihm403h ago
Okay looks to be slightly better
static
staticOP3h ago
good news to hear
ihm40
ihm403h ago
i saw this issue here https://github.com/supabase/cli/issues/1552 related to that
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 ...
ihm40
ihm403h ago
apparently you need to enable supabase webhooks
static
staticOP3h ago
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
static
staticOP3h ago
No description
static
staticOP2h ago
is there a proper way to enable them? or it could be pg_net oh, nvm looks like its already eanbled too
ihm40
ihm402h ago
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 ...
static
staticOP2h ago
okay i'll go ahead and push that
ihm40
ihm402h ago
yeah see if that works, btw i'm assuming this is blocking all tables from being generated?
static
staticOP2h ago
yeah, I don't seen to see any changes
static
staticOP2h ago
okay, so
No description
static
staticOP2h ago
the error is gone now It's this, which was what I was dealing with earlier
ihm40
ihm402h ago
Ahh okay, so i would check your schema file and see if your MessageType enum is being defined before you use it
static
staticOP2h ago
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
ihm40
ihm402h ago
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
static
staticOP2h ago
okay, fair. really appreciate you, and just to confirm after I hopefully get these errors fixed, what would be the next steps?
ihm40
ihm402h ago
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.
static
staticOP2h ago
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?
ihm40
ihm402h ago
switched back in what way?
static
staticOP2h ago
instead of having dev, could I just have it be development?
No description

Did you find this page helpful?