Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 25 additions & 0 deletions lib/bootstrappers/app_builder.rb
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,31 @@ def use_mysql_config_template

end

def use_postgresql_config_template

template 'postgresql_database.yml.erb', 'config/database.yml',:force => true
template 'postgresql_database.yml.erb', 'config/database.yml.example', :force => true

db_user_name = ask("What is your local database user name? [postgres]")
db_password = ask("What is your local database password? ['']")

replace_in_file 'config/database.yml', 'username: root', "username: #{db_user_name}" if db_user_name.present?
replace_in_file 'config/database.yml', 'password: ""', "password: '#{db_password}'" if db_password.present?

end

def use_sqlite_config_template

template 'sqlite_database.yml.erb', 'config/database.yml',:force => true
template 'sqlite_database.yml.erb', 'config/database.yml.example', :force => true

db_user_name = ask("What is your local database user name? [root]")
db_password = ask("What is your local database password? ['']")

replace_in_file 'config/database.yml', 'username: root', "username: #{db_user_name}" if db_user_name.present?
replace_in_file 'config/database.yml', 'password: ""', "password: '#{db_password}'" if db_password.present?

end

end
end
7 changes: 6 additions & 1 deletion lib/bootstrappers/generators/app_generator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -87,8 +87,13 @@ def setup_capistrano
def setup_database
say 'Setting up database'

if 'mysql' == options[:database]
case options[:database]
when 'mysql'
build :use_mysql_config_template
when 'sqlite'
build :use_sqlite_config_template
when 'postgresql'
build :use_postgresql_config_template
end

build :create_database
Expand Down