Skip to content

Instantly share code, notes, and snippets.

@hakjoon
Created August 2, 2017 17:33
Show Gist options
  • Select an option

  • Save hakjoon/ba76aa649e4b5e1b6de2c9522da9ece8 to your computer and use it in GitHub Desktop.

Select an option

Save hakjoon/ba76aa649e4b5e1b6de2c9522da9ece8 to your computer and use it in GitHub Desktop.

Revisions

  1. hakjoon created this gist Aug 2, 2017.
    14 changes: 14 additions & 0 deletions upgrade_pg.sh
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,14 @@
    # You can see what the old version you have is by looking at
    # /usr/local/var/postgres/PG_VERSION

    brew services stop postgresql
    cp -r /usr/local/var/postgres /usr/local/var/postgres_bak #backup db just in case
    mv /usr/local/var/postgres /usr/local/var/postgres<OLD_VERSION> # move it form default location
    initdb /usr/local/var/postgres -E utf8 # create new DB in default location
    pg_upgrade \
    -b /usr/local/Cellar/postgresql/<OLD_VERSION>/bin/ \
    -B /usr/local/Cellar/postgresql/<NEW_VERSION>/bin/ \
    -d /usr/local/var/postgres<OLD_VERSION> \
    -D /usr/local/var/postgres

    pg_ctl -D /usr/local/var/postgres start # see if it worked