rails/rails — pull request #7280 by marcandre (2012-08-07 05:14:21+00:00)
Title: Migration revert

Reversible migrations are very cool.

Some commands are not reversible, for example the removal of a table or a column.

Also, one downside is that it is now more difficult to write the reverse of a migration if `change` is used. When `up` and `down` were used, one could simply swap the code around.

These commits introduce Migration#revert that makes it trivial to revert a past migration (in part or in whole). It also makes it possible to remove a column in a revertible fashion by using `revert { t.add_column ... }`.

Note that `revert` can even be called from legacy migrations using `up` & `down` and that it can revert legacy-style migrations too. For anyone changing their mind every second day, `revert` is fully nestable.

To have complete revertible capability, I would like to introduce a modified syntax for `change_column` that would allow it to be revertible; pull request upcoming when I get a chance...