I am trying to learn deployment using capistrano. I want to deploy the code on a separate folder in my local machine and run migrations after deployment. The capistrano gems used in the project are as follows
capistrano (3.4.0)
capistrano-bundler (1.1.4)
capistrano-ext (1.2.1)
capistrano-rails (1.1.3)
The application is using ruby 2.1 and rails 4.1 The deploy file is as follows
require 'capistrano/rails/migrations'
lock '3.4.0'
set :application, 'capistrano_study'
set :repo_url, 'https://github.com/xxxxxx/capistrano_study.git'
# config valid only for current version of Capistrano
set :stages, ["staging", "production"]
set :default_stage, "staging"
set :user, "prajeesh"
after "deploy:updated", "deploy:migrate"
namespace :deploy do
after :restart, :clear_cache do
on roles(:web), in: :groups, limit: 3, wait: 10 do
# Here we can do anything such as:
# within release_path do
# execute :rake, 'cache:clear'
# end
end
end
end
staging.rb file as follows.
server 'xx.x.x.xxx', user: 'prajeesh', roles: %w{app db web}, my_property: :my_value
set :deploy_to, "/home/prajeesh/Desktop/projects/capistrano_staging"
Database.yml
development:
adapter: mysql2
encoding: utf8
reconnect: false
database: cap_test_staging
pool: 5
username: root
password: xxxxx
# socket: /var/run/mysqld/mysqld.sock
staging:
adapter: mysql2
encoding: utf8
reconnect: false
database: cap_test_staging
pool: 5
username: root
password: xxxxx
When i run the command cap staging:deploy, the deployment is working fine. The issue is that the migrations are not running after deployment.
Does anyone know how to fix this?
Edit:
This is the error that i am getting.
INFO [175f4b0b] Running /usr/bin/env rake db:migrate as
prajeesh@xx.x.x.xxx
DEBUG [175f4b0b] Command: cd /home/prajeesh/Desktop/projects/capistrano_staging/current && ( RAILS_ENV=development /usr/bin/env rake db:migrate )
DEBUG [175f4b0b] rake aborted!
DEBUG [175f4b0b]
cannot load such file -- bundler/setup
If i run the command RAILS_ENV=development /usr/bin/env rake db:migrate directly from the project path, the migration is running but through capistrano it is not working.
Any help would be appreciated.