I am in the process of uploading a website to a server. I can successfully upload the site when i use cap deploy:cold and the site works fine. However, i am planning ahead and want a means of updating the code on the website / running migrations on the db, without losing all the data in the database which seems to happen when i use cap deploy:cold.
My deploy.rb file contains:
require "bundler/capistrano"
#require "csv"
set :application, "my domain"
set :user, "my username"
set :repository, "."
set :deploy_via, :copy
set :deploy_to, "/home/users/#{user}/html/#{application}"
set :ssh_options, { :user => user, :port => 50022 }
set :use_sudo, false
set :scm, :none
role :web, application
role :app, application
role :db, application, :primary => true
namespace :deploy do
task :start do ; end
task :stop do ; end
task :restart, :roles => :app, :except => { :no_release => true } do
run "#{try_sudo} touch
#{File.join(current_path,'tmp','restart.txt')}"
end
end
This code is what i was advised to use by our hosting provider. As i mentioned, cap deploy:cold works successfully and the site works as expected. When I run cap deploy i get the error – We're sorry, but something went wrong. We've been notified about this issue and we'll take a look at it shortly. I noted that the processes called by cap deploy:cold are deploy:update, deploy:migrate and deploy:start. To try to narrow down the problem, i tried running deploy:update on its own, it works with no errors being reported but produces the same error message when i load the site. Running cap deploy:start doesn’t solve the problem.
Is anybody able to shed any light on what might be happening here? Can you also confirm how I should go about uodating the website code & running database migrations in the future, without losing the data currently in the databases?
`
If I’m reading this right, you want one command to update your code and do all pending migrations. Luckily,
cap deploy:migrationsdoes just that. (not to be confused withcap deploy:migratewhich only migrates.If you want to run migrations while only using
cap deploy, you could add:To your recipe.