Changeset 7489
- Timestamp:
- 09/15/07 22:56:07 (1 year ago)
- Files:
-
- trunk/railties/CHANGELOG (modified) (1 diff)
- trunk/railties/lib/tasks/databases.rake (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/railties/CHANGELOG
r7422 r7489 1 1 *SVN* 2 3 * Added db:drop:all to drop all databases declared in config/database.yml [DHH] 2 4 3 5 * Use attribute pairs instead of the migration name to create add and remove column migrations. Closes #9166 [lifofifo] trunk/railties/lib/tasks/databases.rake
r7398 r7489 29 29 ActiveRecord::Base.connection.create_database(config['database'], {:charset => @charset, :collation => @collation}) 30 30 ActiveRecord::Base.establish_connection(config) 31 p "MySQL #{config['database']} database succesfully created"32 31 rescue 33 32 $stderr.puts "Couldn't create database for #{config.inspect}" … … 48 47 end 49 48 50 desc 'Drops the database for the current environment' 49 namespace :drop do 50 desc 'Drops all the local databases defined in config/database.yml' 51 task :all => :environment do 52 ActiveRecord::Base.configurations.each_value do |config| 53 drop_database(config) 54 end 55 end 56 end 57 58 desc 'Drops the database for the current RAILS_ENV' 51 59 task :drop => :environment do 52 config = ActiveRecord::Base.configurations[RAILS_ENV || 'development'] 53 case config['adapter'] 54 when 'mysql' 55 ActiveRecord::Base.connection.drop_database config['database'] 56 when /^sqlite/ 57 FileUtils.rm_f File.join(RAILS_ROOT, config['database']) 58 when 'postgresql' 59 `dropdb "#{config['database']}"` 60 end 60 drop_database(ActiveRecord::Base.configurations[RAILS_ENV || 'development']) 61 61 end 62 62 … … 267 267 end 268 268 269 def drop_database(config) 270 case config['adapter'] 271 when 'mysql' 272 ActiveRecord::Base.connection.drop_database config['database'] 273 when /^sqlite/ 274 FileUtils.rm_f(File.join(RAILS_ROOT, config['database'])) 275 when 'postgresql' 276 `dropdb "#{config['database']}"` 277 end 278 end 279 269 280 def session_table_name 270 281 ActiveRecord::Base.pluralize_table_names ? :sessions : :session