0
0
Supabasecloud~3 mins

Why Running migrations locally and remotely in Supabase? - Purpose & Use Cases

Choose your learning style9 modes available
The Big Idea

What if one simple command could keep your local and cloud databases perfectly matched every time?

The Scenario

Imagine you have a database for your app. You make changes to its structure by hand on your computer, then try to do the same on the cloud server. You have to remember every change and type it again carefully.

The Problem

This manual way is slow and risky. You might forget a step or make a typo. Your app could break because the local and remote databases don't match. Fixing these mistakes takes a lot of time and stress.

The Solution

Running migrations locally and remotely means writing your database changes once and applying them automatically everywhere. This keeps your databases in sync without errors or extra work.

Before vs After
Before
ALTER TABLE users ADD COLUMN age INT;
-- Then manually run the same on remote
After
supabase migration up
-- Applies pending migrations remotely (local via supabase start)
What It Enables

You can update your database safely and quickly, whether on your computer or in the cloud, without worrying about mistakes.

Real Life Example

A developer updates the user profile table to add a new field. They run the migration command once, and both their local setup and the live app's database update perfectly in sync.

Key Takeaways

Manual database updates are slow and error-prone.

Migrations automate and sync changes locally and remotely.

This saves time and prevents app-breaking mistakes.