Skip to content

Instantly share code, notes, and snippets.

@tjmcewan
Created April 5, 2011 00:47
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tjmcewan/902802 to your computer and use it in GitHub Desktop.
Save tjmcewan/902802 to your computer and use it in GitHub Desktop.
Rails agnostic database.yml
<%
app = "awesome_application"
mysql_version = case Rails.version.first.to_i
when 3 then 'mysql2'
when 2 then 'mysql'
else
raise 'Version not supported'
end
%>
defaults: &defaults
adapter: <%= mysql_version %>
encoding: utf8
reconnect: false
pool: 5
username: root
password:
host: localhost
development:
database: <%= app + "_dev" %>
<<: *defaults
test:
database: <%= app + "_test" %>
<<: *defaults
production:
database: <%= app + "_dev" %>
<<: *defaults
@tjmcewan
Copy link
Author

tjmcewan commented Apr 5, 2011

GOTCHA: heroku db:pull (Taps) doesn't parse the ERB so if you're using this w/ Heroku you'll have to put the dev db name in normally.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment