Skip to content

Instantly share code, notes, and snippets.

@nagachika
Forked from jugyo/Rakefile
Created May 15, 2012 16:37
Show Gist options
  • Save nagachika/2703126 to your computer and use it in GitHub Desktop.
Save nagachika/2703126 to your computer and use it in GitHub Desktop.
the db:migrate task using ActiveRecord without Rails
require 'bundler/setup'
require 'active_record'
require 'logger'
namespace :db do
desc "Migrate the database through scripts in db/migrate. Target specific version with VERSION=x"
task :migrate => :environment do
ActiveRecord::Migrator.migrate('db/migrate', ENV["VERSION"] ? ENV["VERSION"].to_i : nil )
end
task :environment do
ActiveRecord::Base.logger = Logger.new(STDOUT)
require_relative './config/db'
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment