2014-04-14 29 views
2

我試圖部署這樣的部署軌sqlite3的數據庫:如何使用Capistrano的

bundle exec cap deploy:cold 
RAILS_ENV=production rake db:migrate 
bundle exec cap deploy:migrate 

,但所有的時間顯示在日誌文件中的錯誤:

I, [2014-04-14T14:15:14.853543 #10769] INFO -- : Started GET "https://stackoverflow.com/users/sign_up" for  
176.192.228.14 at 2014-04-14 14:15:14 -0400 
I, [2014-04-14T14:15:14.856055 #10769] INFO -- : Processing by 
Devise::RegistrationsController#new as HTML 
I, [2014-04-14T14:15:14.857398 #10769] INFO -- : Completed 500 Internal Server Error 
in 1ms 
F, [2014-04-14T14:15:14.860844 #10769] FATAL -- : 
ActiveRecord::StatementInvalid (Could not find table 'users') 

但在當前/ DB文件夾是創建了production.sqlite3。

在localhost:3000它工作正常。

我怎樣才能遷移db生產與capistrano?

我使用nginx的和麒麟,這是我的回購https://github.com/EgorkZe/bh

回答

3

在生產中使用SQLite工作,因爲每次你部署你entiredb被留在老版本的文件夾的新版本是非常有問題的,你可以做什麼時部署添加此命令:

task :copy_sqlite, roles: :app do 
    run "cp #{current_path}/db/production.sqlite3 #{release_path}/db/" 
end 

只需添加這個before rake db:migrate,它會解決你的問題。

我強烈的建議轉移到PostgreSQL/MySQL。

+1

你或許應該符號鏈接,而不是複製。 –

3

更重要的是,改變你的數據庫配置:

production: 
    adapter: sqlite3 
    database: /absolute/path/to/shared/db/production.sqlite3 # instead of db/production.sqlite3