From 09e7502d422952eec1635dae697460c3737c1e91 Mon Sep 17 00:00:00 2001 From: hakanensari Date: Fri, 14 Mar 2014 11:45:14 +0000 Subject: [PATCH] Add db migrate task --- Rakefile | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/Rakefile b/Rakefile index d5d140b..f19da96 100644 --- a/Rakefile +++ b/Rakefile @@ -22,4 +22,17 @@ Rake::TestTask.new do |t| t.verbose = true 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]