We're sorry but this app doesn't work properly without JavaScript enabled. Please enable it to continue.

This lesson's interactive features are locked, please to keep using them

Down Migration

The migration we applied ended up causing trouble in production! It's possible the app wasn't ready for the new columns.

In situations like this, we need to roll back the changes safely using a down migration.

Why Down Migrations Matter

Down migrations allow us to:

  • Undo changes introduced by an up migration
  • Quickly recover from bugs or compatibility issues in production
  • Keep our schema consistent across environments (local, staging, production)

A well-written down migration should completely reverse the changes made in the up migration. In our case, that means removing the two columns we just added.

For example, to remove a column you can use the DROP COLUMN command:

ALTER TABLE users
DROP COLUMN email;

Click to play video

Assignment

Complete the following down migration:

This will revert the schema to the original state.