Class: RedmineInstaller::Database
- Extended by:
- Utils
- Defined in:
- lib/redmine-installer/database.rb
Defined Under Namespace
Classes: Base, MySQL, PostgreSQL
Constant Summary
Constants included from Utils
Class Method Summary collapse
Methods included from Utils
class_name, create_dir, env_user, error, logger, ok, pastel, print_title, prompt, run_command
Class Method Details
.create_config(redmine) ⇒ Object
5 6 7 8 9 10 11 12 13 14 15 16 17 |
# File 'lib/redmine-installer/database.rb', line 5 def self.create_config(redmine) # Maybe: enum_select klass = prompt.select('What database do you want use?') do || .choice 'MySQL', MySQL .choice 'PostgreSQL', PostgreSQL end # Get parameters and create configuration database = klass.new(redmine) database.get_parameters database.make_config database end |
.init(redmine) ⇒ Object
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 |
# File 'lib/redmine-installer/database.rb', line 19 def self.init(redmine) unless File.exist?(redmine.database_yml_path) error "Database configuration files does not exist on #{redmine.root}." end definitions = YAML.load_file(redmine.database_yml_path, aliases: true) definition = definitions['production'] unless definition.is_a?(Hash) error 'Unknow database definition' end case definition['adapter'] when 'mysql', 'mysql2' klass = MySQL when 'pg', 'postgresql' klass = PostgreSQL else error "Unknow database adapter #{definition['adapter']}." end database = klass.new(redmine) database.set_paramaters(definition) database end |