def migrate(direction)
      return unless respond_to?(direction)

      case direction
      when :up   then announce_migration "migrating"
      when :down then announce_migration "reverting"
      end

      time = Benchmark.measure { send(direction) }

      case direction
      when :up   then announce_migration "migrated (%.4fs)" % time.real; puts
      when :down then announce_migration "reverted (%.4fs)" % time.real; puts
      end
    end
def migrate(direction)
      return unless respond_to?(direction)

      case direction
      when :up   then announce_migration "migrating"
      when :down then announce_migration "reverting"
      end

      time = Benchmark.measure { send(direction) }

      case direction
      when :up   then announce_migration "migrated (%.4fs)" % time.real; puts
      when :down then announce_migration "reverted (%.4fs)" % time.real; puts
      end
    end
Execute this migration in the named direction.

 The advantage of using this instead of directly calling up or down is that
 this method gives informative output and benchmarks the time taken.