New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Allow optional -D/--pgdata flag for PG upgrade #49135
Allow optional -D/--pgdata flag for PG upgrade #49135
Conversation
Postgres can be installed with different data directories, or with a non-default location. This allows a user to upgrade those instances too.
require "optparse" | ||
options = {} | ||
OptionParser.new do |opts| | ||
opts.on("-D", "--pgdata DATADIR", "Location of the database configuration files.") do |data_dir| |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I mirrored the option names from pg_ctl
in hopes of keeping it consistent for folks using that option. But I'm happy to use another name.
That's never done by Homebrew's formula, though, right? |
I think we're talking about different things here, and it's probably my fault for saying "can be installed into different data directories." Postgres is installed, by Homebrew, into wherever Homebrew is configured to install things. On my machine, that's: brew --prefix
/usr/local That's where the PostgreSQL binaries and such live. So when you When initializing, starting, or stopping an instance of Postgres, you can tell it which initdb -D <some/path>
pg_ctl -D <some/path> start
pg_ctl -D <some/path> stop If you don't provide this option, it uses the $ brew info postgresql
postgresql: stable 12.1 (bottled), HEAD
[... snip ...]
==> Caveats
To migrate existing data from a previous major version of PostgreSQL run:
brew postgresql-upgrade-database
To have launchd start postgresql now and restart at login:
brew services start postgresql
Or, if you don't want/need a background service you can just run:
pg_ctl -D /usr/local/var/postgres start
[... snip ...] That last line Does that make sense? |
Yes, thanks for the complete explanation. My thinking is that unless |
I understand the hesitation, for sure. However, the option to specify a datadir is so fundamental to PostgreSQL that it's not really option. Similarly, the homebrew-core/Formula/postgresql.rb Line 88 in 69150f8
In its current form, My hope was to allow an optional Does that make a better case for the proposed change? Or would a corresponding change in the formula itself need to be proposed and accepted? Thank you for your time and all of the effort you put into this project. |
This is intentional behaviour.
Homebrew intentionally filters out all environment variables to make a clean and consistent configuration. As a result and discussion above: sorry but passing on this PR.
Thanks for the kind words and the PR |
Postgres can be installed with different data directories, or with a non-default location. This allows a user to upgrade those instances too.
brew install --build-from-source <formula>
, where<formula>
is the name of the formula you're submitting?brew test <formula>
, where<formula>
is the name of the formula you're submitting?brew audit --strict <formula>
(after doingbrew install <formula>
)?This is for an external command, rather than a formula, so I'm not sure the later three apply. That said, I have tested this locally with both the defaults and a
--pgdata ~/.pgdata
option and successfully upgraded from PG 11 to 12.