Pull Remote Database Changes with Supabase

Ben Patton
InstructorBen Patton
Share this video with your friends

Social Share Links

Send Tweet
Published 8 months ago
Updated a week ago

It is common, when working on a team, for changes to have been applied to a remote database and for your local instance to be out of sync.

By running npx supabase db pull we can pull any changes to our remote database schema to keep our local database in sync.

[00:00] In a typical workflow, you might have more than one developer working on any given project. So say in your main remote branch, another developer has made changes, and those have been picked up either through CICD. And now let's say you have a another column. So let's insert a column. We're just gonna call this user ID [00:19] and we're just going to give it a type of u u ID and then we can just go ahead and save that. And so now we have a user ID column, but on our local database, we do not. So the way that we can do this is just running, MPX SuperBase DB pull. This will grab our remote instance [00:39] and pull down changes in our schema. Okay. If we pull up our terminal, we can see that it applied our local, migration file, and then it went ahead and created another migration for us from the remote database to apply to our local database. We can just say yes. So now we need to run the reset [00:59] command again. Okay. Now if we come back to our project, make sure you refresh and we look at our table, we see we now have our user ID column here that we created on our remote branch. So as a recap, when changes are made to the remote database and you want them locally, you can run super base DB pool, create a migration file, [01:19] and then run super base DB reset and you will have the updated schema on your local database.

egghead
egghead
~ 33 minutes ago

Member comments are a way for members to communicate, interact, and ask questions about a lesson.

The instructor or someone from the community might respond to your question Here are a few basic guidelines to commenting on egghead.io

Be on-Topic

Comments are for discussing a lesson. If you're having a general issue with the website functionality, please contact us at support@egghead.io.

Avoid meta-discussion

  • This was great!
  • This was horrible!
  • I didn't like this because it didn't match my skill level.
  • +1 It will likely be deleted as spam.

Code Problems?

Should be accompanied by code! Codesandbox or Stackblitz provide a way to share code and discuss it in context

Details and Context

Vague question? Vague answer. Any details and context you can provide will lure more interesting answers!

Markdown supported.
Become a member to join the discussionEnroll Today