OneBody

Ignoring database.yml

Posted by: timmorgan on: September 3, 2008

This is something that should be done with all Rails apps as they are sucked into The Git for the first time: ignore the config/database.yml file.

Even with as much as evangelism we do regarding using Capistrano, people will still choose to deploy the simplest way they know how, by cloning directly from GitHub to the server. This creates an undesirable effect once the database.yml file is modified to suit the environment… it is seen as a modification to the OneBody codebase. Changes to this file in the origin repository get pulled down on every update, causing problems.

Unfortunately, we failed to ignore database.yml when we converted OneBody from Subversion to Git many months ago. So it has been in the repo, pointing to a SQLite db, causing problems for commiters and deployers.

Now, we’re biting the bullet and getting it done:

  1. We renamed database.yml to database.yml.example
  2. We added code to environment.rb that will copy the example config into place if no config exists.

The side effect is that in your deployment, when you’re ready to get up to date with the latest and greatest, doing a pull will likely rename or delete your database.yml

The fix: copy your current database.yml to a safe place, and put it back once you’ve done the pull. You should only have to do this once, and we’ll all be past this little annoyance forever. Thank you.

1 Response to "Ignoring database.yml"

It seems like database.yml is always a problem. Where I work they put it in /etc so Operations can control it. That way they can install different versions on developer sandboxes, test pods, and production. You can change the path by setting config.database_configuration_file in the Rails::Initializer.run block.

Leave a Reply