How to set Capistrano to share SQLite database across releases?
Rails applications that expect heavy traffic require a scalable database such as Postgres or MySql. However, SQLite might be sufficient for low-traffic applications or apps in the initial development phase, where you do not want to spend the resources and time required to set up and configure a database such as Postgres or MySQL.
If you are using Capistrano to manage your deployment, the default configuration for the database (database.yml) and Capistrano will result in a new database created for every release. This results in the loss of resources (such as users) that you created in the previous release.
Here are the two quick and simple changes that you can make to have a shared SQLite database across your releases.
First, I like to change the database configuration to have a separate database folder for storing the database. I use
db/database/production.sqlite3
instead of db/production.sqlite3
.
Here is what the database.yml file looks like
The second change is to append the database directory to the list of shared directories.
This setting tells Capistrano to have the database directory shared across releases. For every release, Capistrano will create a symlink for the database directory that will point to the shared database directory