File tree 2 files changed +35
-1
lines changed
2 files changed +35
-1
lines changed Original file line number Diff line number Diff line change @@ -10,7 +10,7 @@ pairing with smart people at Hashrocket.
10
10
11
11
For a steady stream of TILs, [ sign up for my newsletter] ( https://tinyletter.com/jbranchaud ) .
12
12
13
- _ 1013 TILs and counting..._
13
+ _ 1014 TILs and counting..._
14
14
15
15
---
16
16
@@ -568,6 +568,7 @@ _1013 TILs and counting..._
568
568
- [ Storing Emails With citext] ( postgres/storing-emails-with-citext.md )
569
569
- [ String Contains Another String] ( postgres/string-contains-another-string.md )
570
570
- [ Switch Non-Castable Column Type With Using Clause] ( postgres/switch-non-castable-column-type-with-using-clause.md )
571
+ - [ Switch The Running Postgres Server Version] ( postgres/switch-the-running-postgres-server-version.md )
571
572
- [ Temporarily Disable Triggers] ( postgres/temporarily-disable-triggers.md )
572
573
- [ Temporary Tables] ( postgres/temporary-tables.md )
573
574
- [ Terminating A Connection] ( postgres/terminating-a-connection.md )
Original file line number Diff line number Diff line change
1
+ # Switch The Running Postgres Server Version
2
+
3
+ I use [ asdf] ( https://github.com/asdf-vm/asdf ) install and manage multiple
4
+ versions of Postgres on my Mac OSX machine. With ` asdf ` and project-based
5
+ ` .tools-versions ` files, I can control what version of Postgres (` psql ` ) I use
6
+ at a project-level.
7
+
8
+ The one snag with this workflow is managing the currently running server
9
+ version. Lets say I need to switch from a project using ` 12.3 ` to a project
10
+ using ` 13.1 ` . If the Postgres server running on my machine is using the
11
+ Postgres server 12.3, then I'll need to manually stop that server and start up
12
+ the Postgres server 13.1.
13
+
14
+ This can be done like so:
15
+
16
+ ``` bash
17
+ # stop the 12.3 server
18
+ $ $HOME /.asdf/installs/postgres/12.3/bin/pg_ctl \
19
+ -D $HOME /.asdf/installs/postgres/12.3/data \
20
+ stop
21
+
22
+ # start the 13.1 server
23
+ $ $HOME /.asdf/installs/postgres/13.1/bin/pg_ctl \
24
+ -D $HOME /.asdf/installs/postgres/13.1/data \
25
+ start
26
+ ```
27
+
28
+ This uses the specific asdf-versioned ` pg_ctl ` command to stop and start the
29
+ servers.
30
+
31
+ I've found it tedious to dig up these commands each time I need to switch, so I
32
+ added a [ ` switch_pg ` function to my ` ~/.zshrc `
33
+ config] ( https://gist.github.com/jbranchaud/3cda6be6e1dc69c6f55435a387018dac ) .
You can’t perform that action at this time.
0 commit comments