Created
March 12, 2015 14:52
-
-
Save dillonhafer/b993f1e0d3009b55936d to your computer and use it in GitHub Desktop.
Cloning the dev env for tests using MySql
This file contains hidden or 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 :spec do | |
task :clone_structure do | |
environments = YAML.load(File.read('config/database.yml')) | |
test = environments["test"] | |
dev = environments["development"] | |
puts "Deleting #{test["database"]}..." | |
`echo 'DROP DATABASE #{test["database"]};' | mysql -u #{test["username"]} -p'#{test["password"]}'` | |
puts "Creating #{test["database"]}..." | |
`echo 'CREATE DATABASE #{test["database"]};' | mysql -u #{test["username"]} -p'#{test["password"]}'` | |
puts "Importing schema into #{test["database"]} from #{dev["database"]}..." | |
`mysqldump -u #{dev["username"]} -p'#{dev["password"]}' --no-data #{dev["database"]} | mysql -u #{test["username"]} -p'#{test["password"]}' #{test["database"]}` | |
end | |
desc "Clone structure from development to test and load seed data into test" | |
task :prepare => ["spec:clone_structure", :environment] do | |
puts "Creating initial seeds..." | |
# Seed data: | |
# => an initial account and user | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment