tchandy/octopus — pull request #168 by Somewater (2013-04-15 10:24:27+00:00)
Title: Fix migrations roll back

Need to check migration in a block, passed to the method **ActiveRecord::Migration#migrate**.
In the current solution (filtering list of migration, depending on the current connection) there is a situation where it is impossible to rollback.
If there is a migration for shards (using_group "shards" in migration file) and a common database (using "master" in the migration file), the alternation of migration, the rollback is not possible:
```
VERSION TARGET
1 create table users on shards
2 change table users
3 create table stats on master DB
4 some changes on shards <- current
```

If you try to revert to the VERSION=2, it can be expected that the table "stats" will be removed. However, in fact it is not. Database "master" does not see migration #2 (filtering in "migrations_with_octopus" method), an exception **ActiveRecord::UnknownMigrationVersionError** raised (into method **ActiveRecord::Migration#migrate**) and caught inside the method "migrate_with_octopus". Downstream migration of the database "master" is not happening.

Need to check migration in a block to the method of **ActiveRecord::Migration#migrate**. As a result, when you rollback to the VERSION=2, will also remove the table "stats".
Sorry for my bad English.