Skip to content

Commit

Permalink
Fix support for -u and -p for specifying database username and passwo…
Browse files Browse the repository at this point in the history
…rd. Added note about the installer ceasing to function if the username or password is incorrect. Closes refineryGH-469
  • Loading branch information
parndt committed Feb 17, 2011
1 parent c051852 commit 715b97c
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions bin/refinerycms
Expand Up @@ -116,7 +116,14 @@ module Refinery
bundle!

# Ensure the database exists so that queries like .table_exists? don't fail.
run_command("rake -f \"#{@app_path.join('Rakefile')}\" db:create")
puts "\nCreating a new database.."
# Warn about incorrect username or password.
unless @options[:database][:adapter] == 'sqlite3'
note = "NOTE: if your database username is not '#{@options[:database][:username]}'"
note << " or your password is not '#{@options[:database][:password]}' then the installer will stop working here.\n\n"
puts note
end
run_command("rake -f \"#{@app_path.join('Rakefile')}\" db:create", {:fail => "Unable to create the application's database"})
else
# Update the current application.
update!
Expand Down Expand Up @@ -242,8 +249,10 @@ module Refinery
if !$?.success? or rails_output.to_s.length == 0 or rails_output =~ /^(Can't\ initialize|Error)/
puts "Generating Rails application failed. Exiting..."
exit(1)
elsif defined? JRUBY_VERSION
find_and_replace(@app_path.join('Gemfile'), /['|"]sqlite3['|"]/, "'activerecord-jdbcsqlite3-adapter'")
else
if defined? JRUBY_VERSION
find_and_replace(@app_path.join('Gemfile'), /['|"]sqlite3['|"]/, "'activerecord-jdbcsqlite3-adapter'")
end

# Override username and password
find_and_replace('config/database.yml', %r{username:.*}, "username: #{@options[:database][:username]}")
Expand Down

0 comments on commit 715b97c

Please sign in to comment.