refactor: allow setting mariadb/postgres specific root credentials in site config

Signed-off-by: Akhil Narang <me@akhilnarang.dev>
This commit is contained in:
Akhil Narang 2024-12-02 13:22:53 +05:30
parent d9ed458d29
commit d77abb2663
No known key found for this signature in database
GPG key ID: 9DCC61E211BF645F
3 changed files with 18 additions and 6 deletions

View file

@ -127,11 +127,18 @@ def get_root_connection():
if not frappe.flags.root_login:
frappe.flags.root_login = (
frappe.conf.get("root_login") or input("Enter mysql super user [root]: ") or "root"
frappe.conf.get("mariadb_root_login")
or frappe.conf.get("root_login")
or input("Enter mysql super user [root]: ")
or "root"
)
if not frappe.flags.root_password:
frappe.flags.root_password = frappe.conf.get("root_password") or getpass("MySQL root password: ")
frappe.flags.root_password = (
frappe.conf.get("mariadb_root_password")
or frappe.conf.get("root_password")
or getpass("MySQL root password: ")
)
frappe.local.flags.root_connection = frappe.database.get_db(
socket=frappe.conf.db_socket,

View file

@ -64,12 +64,17 @@ def get_root_connection():
if not frappe.flags.root_login:
frappe.flags.root_login = (
frappe.conf.get("root_login") or input("Enter postgres super user [postgres]: ") or "postgres"
frappe.conf.get("postgres_root_login")
or frappe.conf.get("root_login")
or input("Enter postgres super user [postgres]: ")
or "postgres"
)
if not frappe.flags.root_password:
frappe.flags.root_password = frappe.conf.get("root_password") or getpass(
"Postgres super user password: "
frappe.flags.root_password = (
frappe.conf.get("postgres_root_password")
or frappe.conf.get("root_password")
or getpass("Postgres super user password: ")
)
frappe.local.flags.root_connection = frappe.database.get_db(

View file

@ -248,7 +248,7 @@ class TestCommands(BaseTestCommands):
global_config = {
"admin_password": frappe.conf.admin_password,
"root_login": frappe.conf.root_login,
"root_password": frappe.conf.root_password,
"root_password": frappe.conf.mariadb_root_password or frappe.conf.root_password,
"db_type": frappe.conf.db_type,
}
site_data = {"test_site": TEST_SITE, **global_config}