namespace :activeroad do
  namespace :db do
    desc "Migrate the database (options: VERSION=x, VERBOSE=false)."

    task :migrate do
      require 'active_record'

      require 'active_road'
      require 'postgis_adapter'

      ActiveRecord::Base.establish_connection ActiveRoad.database_configuration["default"]

      ActiveRecord::Migration.verbose = (ENV["VERBOSE"] == "true")
      ActiveRecord::Migrator.migrate(%w{db/migrate}, ENV["VERSION"] ? ENV["VERSION"].to_i : nil)
    end
    
  end
end

namespace :activeroad do
  namespace :db do
    desc "Migrate the database (options: VERSION=x, VERBOSE=false)."

    task :migrate do
      require 'active_record'

      require 'active_road'
      require 'postgis_adapter'

      env = (ENV['RAILS_ENV'] or "default")
      ActiveRecord::Base.establish_connection ActiveRoad.database_configuration[env]

      ActiveRecord::Migration.verbose = (ENV["VERBOSE"] == "true")
      ActiveRecord::Migrator.migrate(%w{db/migrate}, ENV["VERSION"] ? ENV["VERSION"].to_i : nil)
    end
    
  end
end

Support RAILS_ENV to migrate test db
Support RAILS_ENV to migrate test db
