blackchestnut / blackchestnut.github.io

Developer notes about Ruby on Rails, React Native, PostgreSQL, etc.
https://kalinichev.net
4 stars 0 forks source link

Upgrade Postgres 9.3 to latest_version on OS X #4

Open blackchestnut opened 8 years ago

blackchestnut commented 8 years ago
#1. Shutdown postgres
launchctl unload ~/Library/LaunchAgents/homebrew.mxcl.postgresql.plist

# NOTE:
# If you have error: ".../homebrew.mxcl.postgresql.plist: No such file or directory"
# Try to find specific version, for me:
launchctl unload /usr/local/opt/postgresql93/homebrew.mxcl.postgresql93.plist

#2. Install latest postgresql
brew update && brew upgrade postgresql
brew unlink postgresql93
brew link --overwrite postgresql
brew services start postgresql

#3. Upgrade data (set your paths)
pg_upgrade \                       
  -d /usr/local/var/postgres \
  -D /usr/local/var/postgres9.5 \
  -b /usr/local/Cellar/postgresql/9.3.5_1/bin/ \
  -B /usr/local/Cellar/postgresql/9.5.4_1/bin/ \
  -v

# NOTE:
# If you have error: "There seems to be a postmaster servicing the old cluster.
# Please shutdown that postmaster and try again."
# Find and remove postmaster.pid
sudo find /usr/local/var -name "postmaster.pid"
rm /usr/local/var/postgres/postmaster.pid

#4. Move data
brew services stop postgresql
mv /usr/local/var/postgres /usr/local/var/postgres9.3
mv /usr/local/var/postgres9.5 /usr/local/var/postgres

#5. Start new postgresql
brew services start postgresql
psql --version # > psql (PostgreSQL) 9.5.4
blackchestnut commented 8 years ago

Fail :) the database anyway lost...

blackchestnut commented 8 years ago

Also readline was broken, hot fix without reinstalling the ruby:

group :development do
  # ...
  gem 'rb-readline'
end