0
0
Supabasecloud~10 mins

Running migrations locally and remotely in Supabase - Step-by-Step Execution

Choose your learning style9 modes available
Process Flow - Running migrations locally and remotely
Start Migration Process
Choose Environment
Local
Run Migration
Check Logs
Success?
NoFix Issues
Yes
End Migration
This flow shows choosing to run migrations either locally or remotely, executing them, checking logs, and handling success or errors.
Execution Sample
Supabase
supabase migration run --local
supabase migration run
supabase migration list
Commands to run migrations locally, then remotely, and check migration status.
Process Table
StepActionEnvironmentResultNext Step
1Start migration processN/AReady to choose environmentChoose environment
2Choose environmentLocalSelected local environmentRun migration locally
3Run migration commandLocalMigration applied successfullyCheck logs
4Check logsLocalNo errors foundSuccess?
5Success?LocalYesEnd migration
6Choose environmentRemoteSelected remote environmentRun migration remotely
7Run migration commandRemoteMigration applied successfullyCheck logs
8Check logsRemoteNo errors foundSuccess?
9Success?RemoteYesEnd migration
10End migrationN/AMigration process completeProcess finished
💡 Migration process ends after successful migration on chosen environment.
Status Tracker
VariableStartAfter Step 2After Step 3After Step 5After Step 6After Step 7After Step 9Final
EnvironmentNoneLocalLocalLocalRemoteRemoteRemoteNone
Migration StatusNot startedNot startedSuccessSuccessNot startedSuccessSuccessComplete
LogsEmptyEmptyNo errorsNo errorsEmptyNo errorsNo errorsReviewed
Key Moments - 3 Insights
Why do we check logs after running migrations?
Checking logs confirms if migrations applied correctly or if errors occurred, as shown in steps 4 and 8 in the execution table.
What happens if migration fails on remote environment?
If migration fails, logs will show errors and the process will move to fixing issues before retrying, which is implied after step 8 if success is No.
Can we run migrations locally and remotely in one command?
No, migrations must be run separately for local and remote environments, as shown by separate steps 3 and 7.
Visual Quiz - 3 Questions
Test your understanding
Look at the execution table, what is the migration status after step 3?
ASuccess
BNot started
CFailed
DIn progress
💡 Hint
Check the 'Migration Status' column after step 3 in the variable_tracker.
At which step does the process confirm migration success on the remote environment?
AStep 7
BStep 9
CStep 8
DStep 10
💡 Hint
Look at the 'Success?' action for the remote environment in the execution_table.
If logs showed errors after running migration locally, what would be the next step?
AEnd migration
BRun migration remotely
CFix issues
DCheck migration status
💡 Hint
Refer to the flow where 'Success?' is No leading to 'Fix Issues'.
Concept Snapshot
Running migrations means applying database changes.
Choose environment: local or remote.
Run migration command for chosen environment.
Check logs to confirm success or find errors.
Fix issues if migration fails, then retry.
Repeat for each environment as needed.
Full Transcript
This visual execution shows how to run database migrations using Supabase locally and remotely. First, you start the migration process and choose whether to run it locally or remotely. Then you run the migration command for that environment. After running, you check the logs to see if the migration succeeded or if there were errors. If successful, the process ends. If there are errors, you fix them before retrying. This process is repeated separately for local and remote environments to keep databases in sync.