Vizkrig Vizkrig - 11 months ago 81
Ruby Question

Why do some Rails projects use multiple database.yml files with different extensions (mysql, postgresql etc)?

I've seen this in the source code of Gitlab

Managed to run bundle install successfully. But while running the server with

rails s
command an error is shown saying database.yml is missing. My first thought was to rename database.yml.mysql to database.yml but resisted the temptation for monkey patches. I would like to know why this was done and what's the underlying standard behind this convention.

Answer Source

Since database.yml should not be committed to the source code for various reasons (their .gitignore explicitly removes database.yml from the repo), maintainers tend to put .yml.template as a guide for those would fork the repo. It's not meant to be renamed but rather copied as renaming it would be removing the template.

The multiple extensions (i.e .mysql, .postgres) are just there for you to know what to copy when you use different databases.