instance method create_database

Ruby on Rails 3.1.12

Since v3.1.12 Last seen in v3.1.12

Signature

create_database(name, options = {})

Create a new MySQL database with optional :charset and :collation. Charset defaults to utf8.

Example:

create_database 'charset_test', :charset => 'latin1', :collation => 'latin1_bin'
create_database 'matt_development'
create_database 'matt_development', :charset => :big5

Parameters

name req
options opt = {}
Source
# File activerecord/lib/active_record/connection_adapters/mysql2_adapter.rb, line 393
      def create_database(name, options = {})
        if options[:collation]
          execute "CREATE DATABASE `#{name}` DEFAULT CHARACTER SET `#{options[:charset] || 'utf8'}` COLLATE `#{options[:collation]}`"
        else
          execute "CREATE DATABASE `#{name}` DEFAULT CHARACTER SET `#{options[:charset] || 'utf8'}`"
        end
      end

Defined in activerecord/lib/active_record/connection_adapters/mysql2_adapter.rb line 393 · View on GitHub · Improve this page · Find usages on GitHub

Defined in ActiveRecord::ConnectionAdapters::Mysql2Adapter

Type at least 2 characters to search.

↑↓ navigate · open · esc close