-
-
Save cllns/2fd509797fedfeb112e6 to your computer and use it in GitHub Desktop.
Capistrano (VERSION 3) recipe for using yaml_db to pull data into local database
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
# Add this to your config/deploy.rb | |
# Then run it with: | |
# | |
# cap production db:pull | |
# | |
# (or with `bundle exec` in front, if necessary) | |
# | |
# For Capistrano version 2, use the original script, that this was forked from. | |
# | |
# Note, you need to add: | |
# | |
# gem 'yaml_db' | |
# | |
# to your Gemfile, and deploy it (so your remote server has it as well) | |
namespace :db do | |
desc 'Pull remote database to dev' | |
task :pull do | |
on roles(:db) do | |
within release_path do | |
with rails_env: fetch(:rails_env) do | |
info "Dumping #{fetch(:rails_env)} database" | |
rake "db:data:dump" | |
info "Downloading dump of database" | |
download! "#{release_path}/db/data.yml", "db/data.yml" | |
info "Loading dump into current database" | |
`rake db:drop db:create db:schema:load db:data:load` | |
end | |
end | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment