Skip to content

Commit

Permalink
Patching db:dump and db:clone_prod_to_staging to do the right thing i…
Browse files Browse the repository at this point in the history
…f the mysql2 gem is being used
  • Loading branch information
kiere committed Mar 8, 2011
1 parent c41cc8f commit 300af54
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions lib/eycap/recipes/database.rb
Expand Up @@ -19,7 +19,7 @@
run("cat #{shared_path}/config/database.yml") { |channel, stream, data| @environment_info = YAML.load(data)[rails_env] }
dump

if @environment_info['adapter'] == 'mysql'
if ['mysql', 'mysql2'].include? @environment_info['adapter']
run "gunzip < #{backup_file}.gz | mysql -u #{dbuser} -p -h #{staging_dbhost} #{staging_database}" do |ch, stream, out|
ch.send_data "#{dbpass}\n" if out=~ /^Enter password:/
end
Expand All @@ -37,7 +37,7 @@
on_rollback { run "rm -f #{backup_file}" }
run("cat #{shared_path}/config/database.yml") { |channel, stream, data| @environment_info = YAML.load(data)[rails_env] }

if @environment_info['adapter'] == 'mysql'
if ['mysql', 'mysql2'].include? @environment_info['adapter']
dbhost = @environment_info['host']
if rails_env == "production"
dbhost = environment_dbhost.sub('-master', '') + '-replica' if dbhost != 'localhost' # added for Solo offering, which uses localhost
Expand Down

0 comments on commit 300af54

Please sign in to comment.