Guest User

Untitled

a guest
Apr 17th, 2018
122
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.86 KB | None | 0 0
  1. namespace :create do
  2. desc 'Create all the local databases defined in config/database.yml'
  3. task :all => :environment do
  4. ActiveRecord::Base.configurations.each_value do |config|
  5. # Skip entries that don't have a database key, such as the first entry here:
  6. #
  7. # defaults: &defaults
  8. # adapter: mysql
  9. # username: root
  10. # password:
  11. # host: localhost
  12. #
  13. # development:
  14. # database: blog_development
  15. # <<: *defaults
  16. next unless config['database']
  17. # Only connect to local databases
  18. if config['host'] == 'localhost' || config['host'].blank?
  19. create_database(config)
  20. else
  21. p "This task only creates local databases. #{config['database']} is on a remote host."
  22. end
  23. end
  24. end
  25. end
Add Comment
Please, Sign In to add comment