Reputation: 16383
I had a functioning ruby on rails app but I have managed to delete my config/database.yml
file. It was marked in the .gitignore
file so I cannot get restore it from github or older commits. The posgresql database should still be there. How do I recreate the database.yml
file.
Upvotes: 1
Views: 824
Reputation: 1283
You need to manually recreate it. First use psql -d postgres
. Then at the command prompt type \l
which will list out the names of your different databases. Suppose the relevant development one is app_name_development
. Then type \q
to exit psql
and then use psql app_name_development
to access your development database. Type \du
to find out the user role name. Suppose it is app_name
. Then use a database schema from another app to insert this information.
Here is an example database.yml from a project (rails 5).
default: &default
adapter: postgresql
encoding: unicode
pool: <%= ENV.fetch("RAILS_MAX_THREADS") { 5 } %>
development:
<<: *default
database: app_name_development
test:
<<: *default
database: app_name_test
production:
<<: *default
database: app_name_production
username: app_name
password: <%= ENV['APP_NAME_DATABASE_PASSWORD'] %>
Upvotes: 1