Adding a Capistrano Task11:39 with Jay McGavren
Setting up your database is something that's unique to your app. It's not practical for Capistrano to do for you by default. You need to provide a task to create the database. If we were doing it manually, we'd change into the app directory and running "rails db:setup" in the "production" environment. We need to create a Capistrano task to do the same thing.
Add the following code to
namespace :deploy do desc "Performs first deploy to a server" task :initial do before "deploy:migrate", "deploy:create_db" invoke "deploy" end desc "Runs rails db:setup" task :create_db do on roles(:db) do within release_path do with rails_env: fetch(:rails_env) do execute :rails, "db:setup" end end end end end
The task can then be run with
bundle exec cap production deploy:initial.
You need to sign up for Treehouse in order to download course files.Sign up