rails/rails — Issue #5077: Mark migrations as bad to be rolledback.
Author: eloyesp
Created: 2012-02-17 19:09:44+00:00
State: open

I have an idea that should simplify migrations problems.

Suppose I make a migration that get distributed on many servers, then I notice it is wrong.
It should not run, but it may have already ran. Then I want it to stop this error.
The recommended way to handle this situation is not easy, so I have 2 options:
1. I could add another migration that undo this.
2. I could run db:rollback on every server it has run, and to delete the migration.

The 1, has a problem, if it destroys data or if it causes errors, problems will arise (given that the migration will run)
The option 2 has the problem of being difficult and error prone.

So I think why not to mark the migration as bad.
``` ruby
def bad?; true; end
```
When ruby notice a bad migration has run it ask to rollback (on db:migrate) and if it has not it should skip it.