问题
I moved everything that I had in /opt/local
(where Macports' things lived) into ~/.macports
. That included my old postgres database cluster.
Then I installed postgres using Homebrew and ran the setup that it told me to (creating a new database cluster in /usr/local
).
In my project, I ran rake db:drop:all
and rake db:create
. These did their work cheerfully.
But when I tried to rake db:migrate
, postgres and rails fight and tell me
rake aborted!
PGError: ERROR: unrecognized time zone name: "UTC"
: SET time zone 'UTC'
I don't know what they're talking about, though. I found this article about a config.time_zone
bug slightly illuminating, but not enough to find my way.
Thanks!
回答1:
I was getting this error and simply need to start postgres manually:
pg_ctl -D /usr/local/var/postgres -l /usr/local/var/postgres/server.log start
You can also stop it:
pg_ctl -D /usr/local/var/postgres stop -s -m fast
回答2:
After much head banging, I solved this problem by running:
env ARCHFLAGS="-arch x86_64" gem install pg
回答3:
I'm not completely sure how I fixed it, but uninstalling Postgres and reinstalling it (and following the setup instructions it gives very carefully) got it working.
来源:https://stackoverflow.com/questions/4154774/rails-and-postgres-arent-getting-along-after-switching-from-macports-to-homebre