Last active
December 14, 2016 01:28
-
-
Save hardbap/61592823bd53342a8452be96f78c83f7 to your computer and use it in GitHub Desktop.
Upgrading postgresql from 9.4.x to 9.5.x with Hstore
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Orignal instructions here: https://kkob.us/2016/01/09/homebrew-and-postgresql-9-5/ | |
1. Stop postgresql | |
$ launchctl unload ~/Library/LaunchAgents/homebrew.mxcl.postgresql.plist | |
2. Install postgresql 9.5 | |
$ brew update && brew upgrade postgresql | |
3. Make a new 9.5 database | |
$ initdb /usr/local/var/postgres9.5 -E utf8 | |
4. Rename /usr/local/Cellar/postgresql/9.5.2/bin/pg_ctl -> pg_ctl.bak | |
5. Create a shell wrapper /usr/local/Cellar/postgresql/9.5.2/bin/pg_ctl for pg_ctl.bak | |
#!/bin/sh | |
ln -sf /usr/local/Cellar/postgresql/9.5.2/lib/postgresql /usr/local/lib/ | |
exec /usr/local/Cellar/postgresql/9.5.2/bin/pg_ctl.bak "$@"` | |
6. Rename /usr/local/Cellar/postgresql/9.5.2/bin/pg_dump -> pg_dump.bak | |
7. Create a shell wrapper /usr/local/Cellar/postgresql/9.5.2/bin/pg_dump for pg_dump.bak | |
#!/bin/sh | |
ln -sf /usr/local/Cellar/postgresql/9.4.5_1/lib/postgresql /usr/local/lib/ | |
exec /usr/local/Cellar/postgresql/9.5.2/bin/pg_dump.bak "$@" | |
8. Rename /usr/local/Cellar/postgresql/9.5.2/bin/pg_dumpall -> pg_dumpall.bak | |
9. Create a shell wrapper /usr/local/Cellar/postgresql/9.5.2/bin/pg_dumpall for pg_dumpall.bak | |
#!/bin/sh | |
ln -sf /usr/local/Cellar/postgresql/9.4.5_1/lib/postgresql /usr/local/lib/ | |
exec /usr/local/Cellar/postgresql/9.5.2/bin/pg_dumpall.bak "$@" | |
10. Make all the wrappers executable with `chmod +x` | |
11. Migrate the data to the new 9.5 db `$ pg_upgrade -d /usr/local/var/postgres -D /usr/local/var/postgres9.5 -b /usr/local/Cellar/postgresql/9.4.5_1/bin/ -B /usr/local/Cellar/postgresql/9.5.2/bin/ -v` | |
12. Remove the shell wrappers and rename the .bak files to original names | |
13. Move the 9.5 data directory to where postgresql wants it | |
$ mv /usr/local/var/postgres /usr/local/var/postgres9.4 | |
$ mv /usr/local/var/postgres9.5 /usr/local/var/postgres | |
14. Start the new 9.5 server | |
15. Remove and reinstall the pg gem |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment