Class: RailsInstaller::Database::Mysql

Inherits:
RailsInstaller::Database show all
Defined in:
lib/rails-installer/databases.rb

Overview

Mysql DB class, thanks Phillip Toland

Class Method Summary collapse

Methods inherited from RailsInstaller::Database

backup, connect, create, database_yml, db_host, db_name, db_user, dbs, inherited, restore

Class Method Details

.create_database(installer) ⇒ Object

Create a MySQL database.



255
256
257
258
259
260
261
# File 'lib/rails-installer/databases.rb', line 255

def self.create_database(installer)
  installer.message "Creating MySQL database"
  base_command = "mysql -u #{db_user installer} "
  base_command << "-p#{installer.config['db_password']}" if installer.config['db_password']
  system("#{base_command} -e 'create database #{db_name installer}'")
  system("#{base_command} -e 'create database #{db_name installer}_test'")
end

.yml(installer) ⇒ Object



233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
# File 'lib/rails-installer/databases.rb', line 233

def self.yml(installer)
  %Q{
  login: &login
    adapter: mysql
    host: #{db_host installer}
    username: #{db_user installer}
    password: #{installer.config['db_password']}
    database: #{db_name installer}

  development:
    <<: *login

  production:
    <<: *login

  test:
    database: #{db_name installer}_test
    <<: *login
  }
end