Skip to content

Instantly share code, notes, and snippets.

@cllns
Forked from technicalpickles/deploy.rb
Last active August 29, 2015 14:13
Show Gist options
  • Save cllns/2fd509797fedfeb112e6 to your computer and use it in GitHub Desktop.
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
# 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