Exemple about getting back to 9.6.6 from 9.6.7
brew services stop postgresql brew services stop email@example.com brew uninstall postgresql brew uninstall firstname.lastname@example.org rm -rf /usr/local/var/postgres .psql_history .psqlrc .psql.local .pgpass .psqlrc.local
Select the Postgres.app release having the desired version here. Install it, "Initialize" the server then run:
sudo mkdir -p /etc/paths.d && echo /Applications/Postgres.app/Contents/Versions/9.6/bin | sudo tee /etc/paths.d/postgresapp
Reboot the shell.
The PostgreSQL version of the project I'm working on at work is
9.6.6. The problem is that my machine uses a later version. It results in conflicts with the
db/structure file each time I run a
Like most dev running on macOS, I usually use Homebrew. It allows to easily switch to another installed version of a formula by running
brew switch formula@version. As you guess I tried, but the problem is that Homebrew only handles major versions of each release and I need a specific minor version.
Because I also need to switch between old and recent Rails projects, I often have to change the running PostgreSQL version. My current solution is to use the Postgres.app.
If you already have PostgreSQL installed on your system via Homebrew but want to use a specific version (like a previous one) with Postgres.app, just follow these steps:
1. Remove all PostgreSQL version installed
Check running version
brew services listthen stop them
brew services stop postgresql.
Delete all installed formulas with
brew uninstall postgresqland
brew uninstall postgresql@versionper installed version.
Then delete the related files
rm -rf /usr/local/var postgres .psql_history .psqlrc .psql.local .pgpass .psqlrc.local.
2. Install Postgres.app
Download the release having the desired version.
Install it and create a new server:
- Initialize it.
3. Make PostgreSQL related tools usable with the terminal
This last step allows you to use tools like pg_dump etc. Just run:
sudo mkdir -p /etc/paths.d && echo /Applications/Postgres.app/Contents/Versions/9.6/bin | sudo tee /etc/paths.d/postgresapp`
(Don't forget to replace 9.6 with your version).
Relaunch your shell. Welcome back to the past!
If you have better solution to switch between specific versions of PostgreSQL without external app like I did, don't hesitate to share it! :)
As we all know being a competent software developer or engineer means continuously learning throughout your career. It’s great! That makes this profession exciting and allows to escape everyday routine at work. In fact, it’s not a job anymore - it’s a lifestyle 👩💻👨💻