Topic: sqlite and capistrano

I am deploying a small app that uses an sqlite3 database using Capistrano. Obvioulsy, I don't want my production database to be under version control. What is a sane way to carry the prod.sqlite3 file along with Capistrano deployments? Also, what do I do with the

role :db,  "db01.example.com", :primary => true

line in my deploy.rb? Just delete it?

Last edited by jed.hurt (2006-10-19 16:25:04)

I thought about how mothers feed their babies with tiny little spoons and forks, so I wondered what do Chinese mothers use. Toothpicks?

Re: sqlite and capistrano

You can check in a stub for your database.

Next, create a setup task that establishes a shared/db directory like this:

desc "A setup task to put shared system, log, and database directories in place"
task :setup, :roles => [:app, :db, :web] do
  run <<-CMD
    mkdir -p -m 775 #{release_path} #{shared_path}/system #{shared_path}/db &&
    mkdir -p -m 777 #{shared_path}/log
  CMD
end

You may want to add a command to the above to create the sqlite database initially.

Then, in your after_update_code task, make sure you have symlinked your db/whatever.db to the shared one:

run <<-CMD
ln -nfs #{shared_path}/db/myfine.db #{release_path}/db/myfine.db
rake db:migrate
CMD

Would this work?