Skip to content

Instantly share code, notes, and snippets.

@lukelex
Created October 26, 2013 17:57
Show Gist options
  • Select an option

  • Save lukelex/7172556 to your computer and use it in GitHub Desktop.

Select an option

Save lukelex/7172556 to your computer and use it in GitHub Desktop.
Run ActiveRecord migrations outside of 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