Created
May 19, 2010 22:57
-
-
Save andreimaxim/406962 to your computer and use it in GitHub Desktop.
This file contains 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
APP_ROOT = File.dirname(File.expand_path(__FILE__)) | |
CONFIG_FILE = File.join(APP_ROOT, "db", "config.yml") | |
MIGRATIONS_DIR = File.join(APP_ROOT, "db", "migrate") | |
namespace :db do | |
require "activerecord" | |
task :environment do | |
config = YAML.load_file(CONFIG_FILE) | |
environment = ENV["env"] ? ENV["env"] : "development" | |
ActiveRecord::Base.establish_connection(config[environment]) | |
ActiveRecord::Base.logger = Logger.new(STDOUT) | |
end | |
desc "Migrate the database" | |
task :migrate => :environment do | |
version = ENV["v"].to_i if ENV["v"] | |
ActiveRecord::Migrator.migrate(MIGRATIONS_DIR, version) | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment