PostgreSQL@9.4: Add datadir, PG_VERSION check, and log file helpers

Also remove migration notes from caveats.
master
Markus Wein 2020-11-25 11:46:11 +01:00 committed by Mike McQuaid
parent d0a7519c0e
commit 33c0d031d3
1 changed files with 17 additions and 8 deletions

View File

@ -66,8 +66,20 @@ class PostgresqlAT94 < Formula
return if ENV["CI"]
(var/"log").mkpath
(var/name).mkpath
system "#{bin}/initdb", "#{var}/#{name}" unless File.exist? "#{var}/#{name}/PG_VERSION"
postgresql_datadir.mkpath
system "#{bin}/initdb", postgresql_datadir unless pg_version_exists?
end
def postgresql_datadir
var/name
end
def postgresql_log_path
var/"log/#{name}.log"
end
def pg_version_exists?
(postgresql_datadir/"PG_VERSION").exist?
end
def caveats
@ -76,9 +88,6 @@ class PostgresqlAT94 < Formula
you may need to remove the previous version first. See:
https://github.com/Homebrew/legacy-homebrew/issues/2510
To migrate existing data from a previous major version (pre-9.3) of PostgreSQL, see:
https://www.postgresql.org/docs/9.3/static/upgrading.html
When installing the postgres gem, including ARCHFLAGS is recommended:
ARCHFLAGS="-arch x86_64" gem install pg
@ -86,7 +95,7 @@ class PostgresqlAT94 < Formula
https://docs.brew.sh/Gems,-Eggs-and-Perl-Modules
This formula has created a default database cluster with:
initdb #{var}/postgres
initdb #{postgresql_datadir}
For more details, read:
https://www.postgresql.org/docs/#{version.major}/app-initdb.html
EOS
@ -108,14 +117,14 @@ class PostgresqlAT94 < Formula
<array>
<string>#{opt_bin}/postgres</string>
<string>-D</string>
<string>#{var}/#{name}</string>
<string>#{postgresql_datadir}</string>
</array>
<key>RunAtLoad</key>
<true/>
<key>WorkingDirectory</key>
<string>#{HOMEBREW_PREFIX}</string>
<key>StandardErrorPath</key>
<string>#{var}/log/#{name}.log</string>
<string>#{postgresql_log_path}</string>
</dict>
</plist>
EOS