cmd/brew-postgresql-upgrade-database: use --lc-collate and --lc-ctype (#36497)
parent
edabb7414c
commit
0f598dec43
|
@ -57,12 +57,29 @@ begin
|
|||
server_stopped = true
|
||||
end
|
||||
|
||||
# get 'lc_collate' from old DB"
|
||||
unless quiet_system "#{old_bin}/pg_ctl", "-w", "-D", datadir, "status"
|
||||
system "#{old_bin}/pg_ctl", "-w", "-D", datadir, "start"
|
||||
end
|
||||
|
||||
sql_for_lc_collate = "SELECT setting FROM pg_settings WHERE name LIKE 'lc_collate';"
|
||||
sql_for_lc_ctype = "SELECT setting FROM pg_settings WHERE name LIKE 'lc_ctype';"
|
||||
lc_collate = Utils.popen_read("#{old_bin}/psql", "postgres", "-qtAc", sql_for_lc_collate).strip
|
||||
lc_ctype = Utils.popen_read("#{old_bin}/psql", "postgres", "-qtAc", sql_for_lc_ctype).strip
|
||||
initdb_args = []
|
||||
initdb_args += ["--lc-collate", lc_collate] unless lc_collate.empty?
|
||||
initdb_args += ["--lc-ctype", lc_ctype] unless lc_ctype.empty?
|
||||
|
||||
if quiet_system "#{old_bin}/pg_ctl", "-w", "-D", datadir, "status"
|
||||
system "#{old_bin}/pg_ctl", "-w", "-D", datadir, "stop"
|
||||
end
|
||||
|
||||
ohai "Moving #{name} data from #{datadir} to #{old_datadir}..."
|
||||
FileUtils.mv datadir, old_datadir
|
||||
moved_data = true
|
||||
|
||||
(var/"postgres").mkpath
|
||||
system "#{bin}/initdb", "#{var}/postgres"
|
||||
system "#{bin}/initdb", *initdb_args, "#{var}/postgres"
|
||||
initdb_run = true
|
||||
|
||||
(var/"log").cd do
|
||||
|
|
Loading…
Reference in New Issue