Skip to content

Instantly share code, notes, and snippets.

@alkema
Created January 22, 2009 15:34
Show Gist options
  • Save alkema/50575 to your computer and use it in GitHub Desktop.
Save alkema/50575 to your computer and use it in GitHub Desktop.
require 'rubygems'
require 'active_record'
desc 'migrate legacy table to add column'
namespace :document_manager do
namespace :db do
task :migrate do
ActiveRecord::Base.clear_active_connections!
configs = open('config/database.yml') { |f| YAML.load(f) }
ActiveRecord::Base.logger = Logger.new(STDOUT)
ActiveRecord::Base.configurations = configs
ActiveRecord::Base.establish_connection(ActiveRecord::Base.configurations['document_manager'][ENV['RAILS_ENV'] ])
ActiveRecord::Base.connection.initialize_schema_migrations_table
ActiveRecord::Migration.verbose = true
ActiveRecord::Migrator.migrate("db/document_manager_migrate/", ENV["VERSION"] ? ENV["VERSION"].to_i : nil)
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment