mirror of https://github.com/zulip/zulip.git
upgrade-zulip: Support arbitrary database user and dbname.
Co-authored-by: Adam Birds <adam.birds@adbwebdesigns.co.uk>
This commit is contained in:
parent
1d59330cbc
commit
7ff3c9f966
|
@ -139,6 +139,7 @@ if os.path.exists("/etc/init.d/postgresql"):
|
||||||
if glob.glob("/usr/share/postgresql/*/extension/tsearch_extras.control"):
|
if glob.glob("/usr/share/postgresql/*/extension/tsearch_extras.control"):
|
||||||
# Remove legacy tsearch_extras package references
|
# Remove legacy tsearch_extras package references
|
||||||
run_psql_as_postgres(
|
run_psql_as_postgres(
|
||||||
|
config_file=config_file,
|
||||||
sql_query="DROP EXTENSION IF EXISTS tsearch_extras;",
|
sql_query="DROP EXTENSION IF EXISTS tsearch_extras;",
|
||||||
)
|
)
|
||||||
subprocess.check_call(["apt-get", "remove", "-y", "postgresql-*-tsearch-extras"])
|
subprocess.check_call(["apt-get", "remove", "-y", "postgresql-*-tsearch-extras"])
|
||||||
|
|
|
@ -581,8 +581,10 @@ def get_deploy_options(config_file: configparser.RawConfigParser) -> List[str]:
|
||||||
|
|
||||||
|
|
||||||
def run_psql_as_postgres(
|
def run_psql_as_postgres(
|
||||||
|
config_file: configparser.RawConfigParser,
|
||||||
sql_query: str,
|
sql_query: str,
|
||||||
) -> None:
|
) -> None:
|
||||||
|
dbname = get_config(config_file, "postgresql", "database_name", "zulip")
|
||||||
subcmd = " ".join(
|
subcmd = " ".join(
|
||||||
map(
|
map(
|
||||||
shlex.quote,
|
shlex.quote,
|
||||||
|
@ -590,8 +592,8 @@ def run_psql_as_postgres(
|
||||||
"psql",
|
"psql",
|
||||||
"-v",
|
"-v",
|
||||||
"ON_ERROR_STOP=1",
|
"ON_ERROR_STOP=1",
|
||||||
# TODO: Stop hardcoding the database name.
|
"-d",
|
||||||
"zulip",
|
dbname,
|
||||||
"-c",
|
"-c",
|
||||||
sql_query,
|
sql_query,
|
||||||
],
|
],
|
||||||
|
|
Loading…
Reference in New Issue