In my Rails 4 app, I used to use the default Sqlite3 in development and test, while using Postgresql in production (Heroku).
I just switched from Sqlite3 to Postgresql for all three environments and everything works fine.
My current database.yml looks like that:
default: &default
adapter: postgresql
encoding: unicode
username: XXX
password: <--- empty --->
database: name-of-my-app
pool: 5
development:
<<: *default
host: localhost
# Warning: The database defined as "test" will be erased and
# re-generated from your development database when you run "rake".
# Do not set this db to the same as development or production.
test:
<<: *default
host: localhost
production:
<<: *default
host: localhost
As you can see, I am using the default username (my Mac OSX username) and password (no password) and they are hard coded in the database.yml file.
If I understand correctly from what I have read here and there, this is a double bad practice, and I should instead:
define custom username and passwords
do so with environment variables
Is that correct, and what would be the right approach to doing it?