pg_dump version mismatch in Rails

2019-06-21 20:03发布

When running the rake db:structure:dump command, I encountered the following error:

Larson-2:app larson$ rake db:structure:dump
pg_dump: server version: 9.1.3; pg_dump version: 9.0.4
pg_dump: aborting because of server version mismatch
rake aborted!
Error dumping database

How can I go about updating pg_dump? I have pg 9.1.3 installed, is there a way to update the references inside of Rails to the new version?

When I try to update postgres via homebrew, I get the following output:

Larson-2:app larson$ sudo brew upgrade postgresql
Password:
Error: postgresql already upgraded

3条回答
老娘就宠你
2楼-- · 2019-06-21 20:18

on my machine, the problem was with the PATH. there was a pg_dump v. 9.0.10 on /usr/bin and my server was 9.1.something.

Changing the path to make /usr/local/Cellar/postgres/9..../bin (or whatever is the path to the actual postgres installation you use) come before anything else worked like a breeze. I only had to re-open any open terminal window.

查看更多
放我归山
3楼-- · 2019-06-21 20:22

Here's how I resolved the issue, first update homebrew:

brew update
if you get this error: error: Your local changes to the following files would be overwritten by merge:

then:

cd /usr/local/cellar
git reset --hard FETCH_HEAD

After you finish updating homebrew:
sudo brew install postgresql
Which will install 9.1.3 (or the most current version of pg) and any dependencies.

查看更多
你好瞎i
4楼-- · 2019-06-21 20:23

I had the same issue. Followed the postgres command-line Tools documentation, then had to run rake db:reset then rake db:test:prepare to copy my test database over. After I did those things, it worked.

查看更多
登录 后发表回答