Reputation: 1
In an attempt to solve a NoMethodError I was having, I read somewhere that running rake db:reset
may help fix the problem. I am new to Rails and made the mistake of doing this without knowing exactly what this would do. When I ran it, it successfully dropped my development database (PosgreSQL), but then it hit a fatal error with the following message:
Dropped database 'development'
FATAL: Peer authentication failed for user "postgres"
Couldn't drop database 'test'
rake aborted!
PG::ConnectionBad: FATAL: Peer authentication failed for user "postgres"
Tasks: TOP => db:drop:_unsafe
I tried manually dropping the test database and rerunning rake db:reset
, however the same error occurred. So I lost the data I had in my development database and am stuck with nothing but an empty production database.
I realize that this can probably be fixed by editing the pg_hba.conf
file, but my app is running on my school's high performance cluster (Linux VM) and I don't have write access for that file. What I don't understand is why it was able to drop my development database, but not the rest.
I still have my seeds.rb
and schema.rb
files, so would it be possible to rebuild my databases without messing things up further? Or is there some way for me to fix the problem directly affecting the reset command?
Upvotes: 0
Views: 680
Reputation: 995
rake db:reset
runs db:drop
and db:setup
. db:drop
drops the database for the current RAILS_ENV. If RAILS_ENV is not set, it will attempt to drop both the development and test databases.
Try setting the your RAILS_ENV before running:
RAILS_ENV=development rake db:reset
Upvotes: 2
Reputation: 1
I figured out my problem regarding the authentication failure. When I first set up my database over a week ago I had added host:localhost
to my database.yml
file to circumvent the same issue. However, I only added it for my development database because that was all I needed to access up until now. Adding host:localhost
to the other two databases in the file has fixed my issue.
Upvotes: 0