Created
October 26, 2013 17:57
-
-
Save lukelex/7172556 to your computer and use it in GitHub Desktop.
Run ActiveRecord migrations outside of Rails
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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