Install the Supabase CLI, link your project, pull your current schema into a migration file and push future changes safely.
Set up Supabase migrations so my database changes are saved in git
How it works
- Install the Supabase CLI: The CLI is a Terminal tool for managing your project from code. Vovy installs it with Homebrew and runs supabase login, which opens your browser.
- Link your project: Vovy runs supabase init and supabase link with your project ref, then asks for your database password, which you paste yourself.
- Pull your current schema: Vovy runs supabase db pull, which saves every table and policy you made in the dashboard as a migration file.
- Make the next change as a migration: Vovy runs supabase migration new, writes your change as SQL, and shows the file so you see exactly what will happen.
- Push to your live database: Vovy asks, then runs supabase db push, which applies only migrations that haven't run yet. It commits the files to GitHub after.
What you provide
- Your Supabase project
- Your database password
- A git repo
What you get
- Supabase CLI set up and linked
- Your schema saved as code
- A repeatable way to change the database
- Migrations committed to GitHub
FAQ
What's a migration?
A migration is a saved SQL file that changes your database, like adding a column. Running them in order rebuilds your database anywhere.
I made changes in the dashboard. Are they lost?
No. supabase db pull captures them into a migration file, which Vovy does in step three.
Why does db push say remote migration versions not found?
Your live database has a migration history that doesn't match your files. Vovy compares them with supabase migration list and repairs the history.
Related tasks
All tasks