Port Homebrew::Cmd::PostgresqlUpgradeDatabase
This commit is contained in:
parent
c1b1c11a8c
commit
31aa89aa7c
@ -1,15 +1,13 @@
|
||||
# typed: true
|
||||
# typed: strict
|
||||
# frozen_string_literal: true
|
||||
|
||||
require "cli/parser"
|
||||
require "abstract_command"
|
||||
require "formula"
|
||||
|
||||
module Homebrew
|
||||
module_function
|
||||
|
||||
sig { returns(CLI::Parser) }
|
||||
def postgresql_upgrade_database_args
|
||||
Homebrew::CLI::Parser.new do
|
||||
module Cmd
|
||||
class PostgresqlUpgradeDatabase < AbstractCommand
|
||||
cmd_args do
|
||||
description <<~EOS
|
||||
Upgrades the database for the `postgresql` formula.
|
||||
EOS
|
||||
@ -18,12 +16,9 @@ module Homebrew
|
||||
|
||||
hide_from_man_page!
|
||||
end
|
||||
end
|
||||
|
||||
sig { void }
|
||||
def postgresql_upgrade_database
|
||||
postgresql_upgrade_database_args.parse
|
||||
|
||||
sig { override.void }
|
||||
def run
|
||||
odisabled "brew postgresql_upgrade_database",
|
||||
"using new, versioned e.g. `var/postgres@14` datadir and `pg_upgrade`"
|
||||
|
||||
@ -105,7 +100,8 @@ module Homebrew
|
||||
]
|
||||
locale_settings.each do |setting|
|
||||
sql = "SELECT setting FROM pg_settings WHERE name LIKE '#{setting}';"
|
||||
value = Utils.popen_read("#{old_bin}/psql", "postgres", "-qtAX", "-U", ENV.fetch("USER"), "-c", sql).strip
|
||||
value = Utils.popen_read("#{old_bin}/psql", "postgres", "-qtAX", "-U", ENV.fetch("USER"), "-c",
|
||||
sql).strip
|
||||
|
||||
next if value.empty?
|
||||
|
||||
@ -169,3 +165,5 @@ module Homebrew
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -0,0 +1,8 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
require "cmd/postgresql-upgrade-database"
|
||||
require "cmd/shared_examples/args_parse"
|
||||
|
||||
RSpec.describe Homebrew::Cmd::PostgresqlUpgradeDatabase do
|
||||
it_behaves_like "parseable arguments"
|
||||
end
|
Loading…
x
Reference in New Issue
Block a user