Add db migrate task

This commit is contained in:
hakanensari 2014-03-14 11:45:14 +00:00
parent 951a777150
commit 09e7502d42

View File

@ -22,4 +22,17 @@ Rake::TestTask.new do |t|
t.verbose = true t.verbose = true
end end
namespace :db do
desc 'Run database migrations'
task :migrate do
Sequel.extension(:migration)
db = Sequel::DATABASES.first
dir = App.root.join('db/migrate')
opts = {}
opts.update(target: ENV['VERSION'].to_i) if ENV['VERSION']
Sequel::IntegerMigrator.new(db, dir, opts).run
end
end
task :default => [:test] task :default => [:test]