我正在为我的Ruby on Rails应用程序(在Mac OS X 10.9上)使用PostgreSQL数据库.
有关于如何升级PostgreSQL数据库的详细说明吗?
恐怕我会 destruct 数据库中的数据或把它搞砸.
我正在为我的Ruby on Rails应用程序(在Mac OS X 10.9上)使用PostgreSQL数据库.
有关于如何升级PostgreSQL数据库的详细说明吗?
恐怕我会 destruct 数据库中的数据或把它搞砸.
假设您已使用home brew安装和升级Postgres,则可以执行以下步骤.
停止当前Postgres服务器:
launchctl unload ~/Library/LaunchAgents/homebrew.mxcl.postgresql.plist
初始化新的10.1数据库:
initdb /usr/local/var/postgres10.1 -E utf8
运行pg_upgrade
(note: change bin version if you're upgrading from something other than below):
pg_upgrade -v \
-d /usr/local/var/postgres \
-D /usr/local/var/postgres10.1 \
-b /usr/local/Cellar/postgresql/9.6.5/bin/ \
-B /usr/local/Cellar/postgresql/10.1/bin/
-v
以启用详细的内部日志(log)记录
-d
旧数据库群集配置目录
-D
新的数据库群集配置目录
-b
旧的PostgreSQL可执行目录
-B
新的PostgreSQL可执行目录
将新数据移动到位:
cd /usr/local/var
mv postgres postgres9.6
mv postgres10.1 postgres
重新启动Postgres:
launchctl load ~/Library/LaunchAgents/homebrew.mxcl.postgresql.plist
判断/usr/local/var/postgres/server.log
以了解详细信息,并确保新服务器正确启动.
最后,重新安装rails pg
gem
gem uninstall pg
gem install pg
我建议你花些时间阅读这PostgreSQL documentation篇文章,以便准确地理解你在上述步骤中所做的事情,从而最大限度地减少挫折感.