I want to call a thor task from a Migration.
With rake I can write
def self.up
Rake::Task["db:rollback"].invoke
end
But how can i do this with thor?
(The thor command is “thor db:rollback”)
(thor db:rollback is not a option, I want so see the output and the script should abort on errors)
UPDATE:
The migration is called from the Thorfile
It looks like this:
require 'active_record'
class Db < Thor
desc "migrate", "description ..."
def migrate
ActiveRecord::Migrator.migrate(MIGRATIONS_PATH)
end
end
Assuming that
db:rollbackrefers to therollbacktask of theDbclass, then you can do this:You can read more in the docs: http://rdoc.info/github/wycats/thor/master/Thor/Base/ClassMethods#start-instance_method