create_local_database (lib/active_record/merbtasks.rb)

    # File lib/active_record/merbtasks.rb, line 21
      def create_local_database(config)
        # Only connect to local databases
        if config[:host] == 'localhost' || config[:host].blank?
          begin
            ActiveRecord::Base.establish_connection(config)
            ActiveRecord::Base.connection
          rescue
            case config[:adapter]
            when 'mysql'
              @charset   = ENV['CHARSET']   || 'utf8'
              @collation = ENV['COLLATION'] || 'utf8_general_ci'
              begin
                ActiveRecord::Base.establish_connection(config.merge({:database => nil}))
                ActiveRecord::Base.connection.create_database(config[:database], {:charset => (config[:charset] || @charset), :collation => (config[:collation] || @collation)})
                ActiveRecord::Base.establish_connection(config)
                puts "MySQL #{config[:database]} database successfully created"
              rescue
                $stderr.puts "Couldn't create database for #{config.inspect}, charset: #{config[:charset] || @charset}, collation: #{config[:collation] || @collation} (if you set the charset manually, make sure you have a matching collation)"
              end
            when 'postgresql'
              `createdb "#{config[:database]}" -E utf8`
            when 'sqlite'
              `sqlite "#{config[:database]}"`
            when 'sqlite3'
              `sqlite3 "#{config[:database]}"`
            end
          else
            puts "#{config[:database]} already exists"
          end
        else
          puts "This task only creates local databases. #{config[:database]} is on a remote host."
        end
      end