Let's say, like me, you accidentally upgraded PostgresQL or PostGIS or something super important and now you need to go back in time and install the previous version.
-
Find the commit of the old version that you want to install by looking through the Formula/ directory in the
homebrew-core
repo: https://github.com/Homebrew/homebrew-core/commits/master/Formula/ (If the above doesn't work, you'll need to clone thehomebrew-core
repo to your machine and rungit log master -- Formula/<formula name>.rb
). -
Unlink the existing (newer) version:
$ brew unlink <formula_name>
-
Install the old version using formula using a direct link to that commit:
# For example, to install 9.3.2: $ brew install https://raw.githubusercontent.com/Homebrew/homebrew-core/aa049a47b218fda30f9a4a454119ae067a02cf50/Formula/postgis.rb
-
Now you have both versions installed and your updated version should be the linked one:
$ brew info postgis > postgis: stable 2.4.2 (bottled), HEAD > Adds support for geographic objects to PostgreSQL > https://postgis.net/ > /usr/local/Cellar/postgis/2.3.2 (196 files, 75.2MB) * > Poured from bottle on 2018-01-10 at 12:48:54 > /usr/local/Cellar/postgis/2.4.2 (228 files, 91MB) > Poured from bottle on 2018-01-10 at 11:54:37