You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hello,
I'm wondering if there is a way to automate the creation of a Postgres.app managed database server? It would be very handy when setting up new developer machines to be able to also create a Postgres.app server for them. Right now you can obviously run initdb via a shell script, but it's not possible to fully automate the "create a new server" action and have the server appear in the sidebar.
The servers are stored in the user defaults, so you can just use the defaults write com.postgresapp.Postgres2 .... command to programmatically add it to the sidebar.
There's no official docs, but it should be pretty self-explanatory. If it's unclear, feel free to post follow up questions.
The Postgres.app GUI reads the user defaults on launch, so make sure to quit the app before making changes.
Yeah I saw this, but you may wish for the server to be running before you take a next step. If you're bootstrapping a machine or project with some dependencies from homebrew(such as this one), the next steps may require a Postgres.app server to be running and available. It's minor, but it's a bit annoying to block that and say "now go to this UI and press a few buttons".
If you're not against it then I could take a stab at adding an additional AppleScript interface to do this, perhaps? I've got the start of a branch here that adds a create server command with a paramater and inits/starts the server.
You can already start/stop servers without using the GUI -- all the GUI does is call pg_ctl.
But adding AppleScript actions does sound useful! I just did a cursory glance at you branch -- the first thing that jumped out were the try! statements. I assume those are just for testing, but they should be replaced by proper error handling (the error should be reported back to Apple Script).
One caveat with Apple Script is that macOS recently started showing permission dialogs when you try automating an app for the first time, and I haven't found a way around that yet. (But I haven't looked into it yet in detail)
@orf We have been discussing this issue and realised that you have deleted your fork. Is there any chance you still have a copy of your work somewhere on a backup?
Activity
jakob commentedon Apr 19, 2023
The servers are stored in the user defaults, so you can just use the
defaults write com.postgresapp.Postgres2 ....command to programmatically add it to the sidebar.There's no official docs, but it should be pretty self-explanatory. If it's unclear, feel free to post follow up questions.
The Postgres.app GUI reads the user defaults on launch, so make sure to quit the app before making changes.
orf commentedon Apr 19, 2023
Yeah I saw this, but you may wish for the server to be running before you take a next step. If you're bootstrapping a machine or project with some dependencies from homebrew(such as this one), the next steps may require a Postgres.app server to be running and available. It's minor, but it's a bit annoying to block that and say "now go to this UI and press a few buttons".
If you're not against it then I could take a stab at adding an additional AppleScript interface to do this, perhaps? I've got the start of a branch here that adds a
create servercommand with a paramater and inits/starts the server.jakob commentedon Apr 19, 2023
You can already start/stop servers without using the GUI -- all the GUI does is call pg_ctl.
But adding AppleScript actions does sound useful! I just did a cursory glance at you branch -- the first thing that jumped out were the
try!statements. I assume those are just for testing, but they should be replaced by proper error handling (the error should be reported back to Apple Script).One caveat with Apple Script is that macOS recently started showing permission dialogs when you try automating an app for the first time, and I haven't found a way around that yet. (But I haven't looked into it yet in detail)
jakob commentedon Nov 6, 2025
@orf We have been discussing this issue and realised that you have deleted your fork. Is there any chance you still have a copy of your work somewhere on a backup?
orf commentedon Nov 8, 2025
Unfortunately not @jakob, sorry! I cleaned out my forks a while back and this must have got swept up in that.
Sorry!