Skip to content

Instantly share code, notes, and snippets.

@thbar
Created December 14, 2011 15:57
Show Gist options
  • Save thbar/1477151 to your computer and use it in GitHub Desktop.
Save thbar/1477151 to your computer and use it in GitHub Desktop.
Custom capistrano task to do db:schema:load
# cap deploy deploy:db_schema_load
namespace :deploy do
desc "Load the initial schema - it will WIPE your database, use with care"
task :db_schema_load, :roles => :db, :only => { :primary => true } do
puts <<-EOF
************************** WARNING ***************************
If you type [yes], rake db:schema:load will WIPE your database
any other input will cancel the operation.
**************************************************************
EOF
answer = Capistrano::CLI.ui.ask "Are you sure you want to WIPE your database?: "
if answer == 'yes'
run "cd #{current_path} && RAILS_ENV=production bundle exec rake db:schema:load"
else
puts "Cancelled."
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment