Skip to content
This repository has been archived by the owner on Apr 17, 2018. It is now read-only.

Commit

Permalink
Behave like AR does wrt migrating dev and test storages
Browse files Browse the repository at this point in the history
This change makes some rake tasks behave like so:

  rake db:create      # both dev and test repos
  rake db:drop        # only the current env repo
  rake db:automigrate # only the current env repo
  rake db:autoupgrade # only the current env repo
  rake db:migrate     # only the current env repo

Previously, db:drop/automigrate/autoupgrade were
operating on both dev and test repos if RAILS_ENV
was set to development.

While creating both dev and test repos when no
RAILS_ENV is specified (defaults to development)
makes sense, it doesn't make sense to perform the
other operations on both repo envs too.

[#1326 state:resolved]
  • Loading branch information
snusnu committed Jun 17, 2010
1 parent f7895af commit 8bf64e7
Showing 1 changed file with 0 additions and 17 deletions.
17 changes: 0 additions & 17 deletions lib/dm-rails/railties/database.rake
Expand Up @@ -35,9 +35,6 @@ namespace :db do
desc "Drops the database(s) for the current Rails.env - also drops the test database(s) if Rails.env.development?"
task :drop => :environment do
Rails::DataMapper.storage.drop_environment(Rails::DataMapper.configuration.repositories[Rails.env])
if Rails.env.development? && Rails::DataMapper.configuration.repositories['test']
Rails::DataMapper.storage.drop_environment(Rails::DataMapper.configuration.repositories['test'])
end
end


Expand All @@ -48,13 +45,6 @@ namespace :db do
::DataMapper.auto_migrate!(repository.to_sym)
::DataMapper.logger.info "[datamapper] Finished auto_migrate! for :#{repository} repository '#{config['database']}'"
end
if Rails.env.development? && Rails::DataMapper.configuration.repositories['test']
Rails::DataMapper.setup('test')
Rails::DataMapper.configuration.repositories['test'].each do |repository, config|
::DataMapper.auto_migrate!(repository.to_sym)
::DataMapper.logger.info "[datamapper] Finished auto_migrate! for :#{repository} repository '#{config['database']}'"
end
end
end

desc 'Perform non destructive automigration of all repositories in the current Rails.env'
Expand All @@ -64,13 +54,6 @@ namespace :db do
::DataMapper.auto_upgrade!(repository.to_sym)
::DataMapper.logger.info "[datamapper] Finished auto_upgrade! for :#{repository} repository '#{config['database']}'"
end
if Rails.env.development? && Rails::DataMapper.configuration.repositories['test']
Rails::DataMapper.setup('test')
Rails::DataMapper.configuration.repositories['test'].each do |repository, config|
::DataMapper.auto_upgrade!(repository.to_sym)
::DataMapper.logger.info "[datamapper] Finished auto_upgrade! for :#{repository} repository '#{config['database']}'"
end
end
end

desc 'Load the seed data from db/seeds.rb'
Expand Down

0 comments on commit 8bf64e7

Please sign in to comment.