0
0
Supabasecloud~5 mins

Rolling back migrations in Supabase

Choose your learning style9 modes available
Introduction

Rolling back migrations helps you undo changes made to your database. It keeps your data safe when something goes wrong.

You applied a database change that caused errors.
You want to test a previous version of your database schema.
You accidentally ran the wrong migration and need to fix it.
You want to remove a feature that required a database change.
You need to reset your database to a known good state.
Syntax
Supabase
supabase migration rollback [--steps <number>]

The command rolls back the last migration by default.

Use --steps to rollback multiple migrations at once.

Examples
Rolls back the most recent migration.
Supabase
supabase migration rollback
Rolls back the last two migrations.
Supabase
supabase migration rollback --steps 2
Sample Program

This command will undo the last migration applied to your Supabase database.

Supabase
# Run this in your terminal
supabase migration rollback --steps 1
OutputSuccess
Important Notes

Always backup your database before rolling back migrations.

Rolling back migrations may cause data loss if the migration removed or changed tables.

Check migration files to understand what changes will be undone.

Summary

Rolling back migrations helps undo database changes safely.

Use supabase migration rollback with optional --steps to control how many migrations to undo.

Be careful and backup data before rolling back.