Help with mysql and installer

I don’t use mysql, so fixing mysql problems is kind of hard for me :-).

I’d like to get native mysql support into the installer. I’d really
like to get it in today. So I’d like some help. It’s not all that
complex–here’s the important part of the postgres driver:

class Postgresql < RailsInstaller::Database
  def self.yml(installer)
    %Q{
    login: &login
      adapter: postgresql
      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

  # Create a PostgreSQL database.
  def self.create_database(installer)
    installer.message "Creating PostgreSQL database"
    system("createdb -U #{db_user installer} #{db_name installer}")
    system("createdb -U #{db_user installer} #{db_name 

installer}-test")
end
end

Basically, I need a ‘yml’ method that builds a database.yml, and a
create_database method that can create a MySQL db.

If someone can implement this now and let me know, then I can
include it in Typo 4.0.2. The source lives in
http://rails-app-installer.googlecode.com/svn/trunk; you should be
able to check it out via svn.

Scott

On 8/10/06, Scott L. [email protected] wrote:

I’d like to get native mysql support into the installer. I’d really
like to get it in today. So I’d like some help. It’s not all that
complex–here’s the important part of the postgres driver:
[snip]

How’s this:

class Mysql < RailsInstaller::Database
def self.db_host(installer)
installer.config[‘db_host’] || ‘localhost’
end

def self.db_user(installer)
installer.config[‘db_user’] || installer.app_name
end

def self.db_name(installer)
installer.config[‘db_name’] || installer.app_name
end

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

Create a MySQL database.

def self.create_database(installer)
installer.message “Creating MySQL database”
system(“mysql -u #{db_user installer}
-p#{installer.config[‘db_password’]} -e ‘create database #{db_name
installer}’”)
system(“mysql -u #{db_user installer}
-p#{installer.config[‘db_password’]} -e ‘create database #{db_name
installer}-test’”)
end
end

Phil

On 8/10/06, Phillip T. [email protected] wrote:

installer.config['db_host'] || 'localhost'

def self.yml(installer)

def self.create_database(installer)
installer.message “Creating MySQL database”
system(“mysql -u #{db_user installer}
-p#{installer.config[‘db_password’]} -e ‘create database #{db_name
installer}’”)
system(“mysql -u #{db_user installer}
-p#{installer.config[‘db_password’]} -e ‘create database #{db_name
installer}-test’”)
end
end

Thanks. I’ll give this a spin in rails-app-installer 0.1.2 / Typo
4.0.2.

Scott

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs