0
0
Supabasecloud~3 mins

Why Rolling back migrations in Supabase? - Purpose & Use Cases

Choose your learning style9 modes available
The Big Idea

What if you could instantly undo a risky database change with one command?

The Scenario

Imagine you just updated your database with new changes, but suddenly your app breaks because of a mistake in the update.

You try to fix it by manually undoing each change in the database, one by one, hoping nothing else breaks.

The Problem

Manually reversing database changes is slow and risky.

You might forget a step or make a typo, causing more errors.

It's like trying to untangle a knot without knowing how it was tied.

The Solution

Rolling back migrations lets you undo database changes safely and quickly.

It tracks each change and can reverse them automatically, so you don't have to guess or do it by hand.

Before vs After
Before
DROP TABLE users;
ALTER TABLE orders DROP COLUMN discount;
After
supabase db rollback --steps 1
What It Enables

You can fix mistakes instantly and keep your database healthy without stress.

Real Life Example

A developer deploys a new feature but finds a bug in the database schema.

Using rollback, they quickly undo the last migration and fix the bug before users notice.

Key Takeaways

Manual undoing of database changes is error-prone and slow.

Rolling back migrations automates safe reversal of changes.

This keeps your app stable and saves time during fixes.