-fibrous = require 'fibrous'   # TODO remove me
 path = require 'path'
 fse = require 'fs-extra'
 redis = require 'redis'



  # Generate a stub migration file
  generate: fibrous (name) ->
    name = "#{slugify name, '_'}"
    timestamp = (new Date()).toISOString().replace /\D/g, ''
    filename = "#{@opts.path}/#{timestamp}_#{name}.#{@opts.ext}"
    fse.sync.mkdirp @opts.path
    fse.sync.writeFile filename, @opts.template
    filename

      (next) =>
        @redisClient.smembers @setKey(), next
      (migrationsAlreadyRun, next) =>
        if migrationsAlreadyRun?.length
          lastMigrationName = migrationsAlreadyRun.sort()[migrationsAlreadyRun.length - 1]
        if not lastMigrationName
          return next(new Error("No migrations found!"))
        migration = @get(lastMigrationName)
        @log "Reversing migration `#{migration.name}`"
        migration.down (err) =>
          return next(err) if err
          return next(null, lastMigrationName)

      (lastMigrationName, next) =>
        @redisClient.srem @setKey(), lastMigrationName, next
