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
|
# frozen_string_literal: true
|
||||||
|
|
||||||
require "cli/parser"
|
require "abstract_command"
|
||||||
require "formula"
|
require "formula"
|
||||||
|
|
||||||
module Homebrew
|
module Homebrew
|
||||||
module_function
|
module Cmd
|
||||||
|
class PostgresqlUpgradeDatabase < AbstractCommand
|
||||||
sig { returns(CLI::Parser) }
|
cmd_args do
|
||||||
def postgresql_upgrade_database_args
|
|
||||||
Homebrew::CLI::Parser.new do
|
|
||||||
description <<~EOS
|
description <<~EOS
|
||||||
Upgrades the database for the `postgresql` formula.
|
Upgrades the database for the `postgresql` formula.
|
||||||
EOS
|
EOS
|
||||||
@ -18,12 +16,9 @@ module Homebrew
|
|||||||
|
|
||||||
hide_from_man_page!
|
hide_from_man_page!
|
||||||
end
|
end
|
||||||
end
|
|
||||||
|
|
||||||
sig { void }
|
|
||||||
def postgresql_upgrade_database
|
|
||||||
postgresql_upgrade_database_args.parse
|
|
||||||
|
|
||||||
|
sig { override.void }
|
||||||
|
def run
|
||||||
odisabled "brew postgresql_upgrade_database",
|
odisabled "brew postgresql_upgrade_database",
|
||||||
"using new, versioned e.g. `var/postgres@14` datadir and `pg_upgrade`"
|
"using new, versioned e.g. `var/postgres@14` datadir and `pg_upgrade`"
|
||||||
|
|
||||||
@ -105,7 +100,8 @@ module Homebrew
|
|||||||
]
|
]
|
||||||
locale_settings.each do |setting|
|
locale_settings.each do |setting|
|
||||||
sql = "SELECT setting FROM pg_settings WHERE name LIKE '#{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?
|
next if value.empty?
|
||||||
|
|
||||||
@ -168,4 +164,6 @@ module Homebrew
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
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