1
我使用capistrano将我的Rails应用程序部署到我的VPS,但每次部署后,当我访问我的页面时出现错误。日志说:Capistrano部署删除表
I, [2014-11-04T08:20:16.659289 #12482] INFO -- : Started GET "/" for 82.73.170.71 at 2014-11-04 08:20:16 -0500
I, [2014-11-04T08:20:16.662717 #12482] INFO -- : Processing by HomeController#index as HTML
I, [2014-11-04T08:20:16.665979 #12482] INFO -- : Completed 500 Internal Server Error in 3ms
F, [2014-11-04T08:20:16.670152 #12482] FATAL -- :
ActiveRecord::StatementInvalid (Could not find table 'users'):
app/controllers/application_controller.rb:18:in `current_user'
app/helpers/sessions_helper.rb:26:in `logged_in?'
app/controllers/home_controller.rb:4:in `index'
我ssh到我的VPS,去我的Rails根目录并运行RAILS_ENV=production bundle exec rake db:migrate
。在我的db文件夹中,我仍然有production.sqlite3
文件,但它是空的。
我deploy.rb
# config valid only for Capistrano 3.1
lock '3.1.0'
set :application, 'movieseat'
set :repo_url, '[email protected]:alucardu/movieseat.git'
set :deploy_to, '/home/deploy/movieseat'
set :linked_files, %w{config/database.yml config/secrets.yml}
set :linked_dirs, %w{bin log tmp/pids tmp/cache tmp/sockets vendor/bundle public/system}
require 'capistrano-rbenv'
namespace :deploy do
desc 'Restart application'
task :restart do
on roles(:app), in: :sequence, wait: 5 do
execute :touch, release_path.join('tmp/restart.txt')
end
end
after :publishing, 'deploy:restart'
after :finishing, 'deploy:cleanup'
end
那么,为什么Capistrano的删除我的数据库,当我部署?
你是对的。我刚刚检查了部署的输出,在那里找不到任何东西,引起了'rake migrate'或'rake create'。但是它在部署之后发生,所以出了问题。 – 2014-11-04 14:36:55
我已更新我的答案 – blelump 2014-11-04 14:43:36
使得sence,但是当我现在运行它时,我得到了显而易见的错误'/home/deploy/movieseat/shared/db/production.sqlite3不会激发'。但只是将sqlite文件放在那里不会有太大的作用,因为应用程序没有引用使用共享sqlite文件而不是db文件夹中的on。 – 2014-11-04 14:51:17