Created
October 28, 2010 15:58
-
-
Save bluefuton/651662 to your computer and use it in GitHub Desktop.
Capistrano: clone dev database to another stage (for example - cap staging mysql:clone_dev_db)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
namespace :mysql do | |
task :clone_dev_db do | |
require 'ostruct' | |
db_config = OpenStruct.new(YAML.load_file("config/database.yml")) | |
dev_db = db_config.development | |
stage_db = db_config.send(stage) | |
cmd = "mysqldump -u #{dev_db['username']} -h #{dev_db['host']} -p'#{dev_db['password']}' #{dev_db['database']} " + | |
"--add-drop-table | mysql -u #{stage_db['username']} -p'#{stage_db['password']}' -h #{stage_db['host']} #{stage_db['database']}" | |
run cmd | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment