From 33c0d031d31da120dbd2e622f5db58a47efcb456 Mon Sep 17 00:00:00 2001 From: Markus Wein Date: Wed, 25 Nov 2020 11:46:11 +0100 Subject: [PATCH] PostgreSQL@9.4: Add datadir, PG_VERSION check, and log file helpers Also remove migration notes from caveats. --- Formula/postgresql@9.4.rb | 25 +++++++++++++++++-------- 1 file changed, 17 insertions(+), 8 deletions(-) diff --git a/Formula/postgresql@9.4.rb b/Formula/postgresql@9.4.rb index c62408dd174..8249531ffc9 100644 --- a/Formula/postgresql@9.4.rb +++ b/Formula/postgresql@9.4.rb @@ -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 #{opt_bin}/postgres -D - #{var}/#{name} + #{postgresql_datadir} RunAtLoad WorkingDirectory #{HOMEBREW_PREFIX} StandardErrorPath - #{var}/log/#{name}.log + #{postgresql_log_path} EOS