views:

187

answers:

1

I've managed to deploy my app to production using Capistrano, but I don't understand how to deal with my database. I'm using subversion and passenger.

When I run cap deploy, the new deployment starts everything fresh. It wipes out the data that was added to the database. Obviously, there must be a solution, but I'm very surprised not to find anything online about how to deal with this. I've read the Capistrano documentation and many tutorials.

The best I can find is the Advanced Rails recipes books, which talks about putting user-generated content into the shared directory, but it's not exactly on point.

How do you deal with your database when deploying with Capistrano?

+3  A: 

Chances are you are using SQLite, and you are keeping the database in the default location. Your database is not being deleted, more just left behind.

You need to edit your database.yml and tell it to keep your production database in a shared location "../../shared/database.yml" or similar (you may be better off using an absolute path, or for bonus points MySQL).

When you deploy via capistrano it creates a new copy of your app in a timestamped directory. Your database is being left behind in the old timestamped dir.

cwninja
Ah! Ok, yes I was about to switch to mysql, but I've been using sqlite for development and did deploy the first time with sqlite. Looks like it's time to switch to mysql. Thanks.
MikeH
Switched to mysql, and everything works great. This was the problem.
MikeH
Good stuff! Thanks for the accept!
cwninja