Merge pull request #28636 from akhilnarang/separate-db-config-keys

refactor: allow setting mariadb/postgres specific root credentials in site config
This commit is contained in:
Akhil Narang 2024-12-02 15:52:44 +05:30 committed by GitHub
commit 3b6ff70d76
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 23 additions and 13 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

@ -142,11 +142,6 @@ def install_db(
if not db_type:
db_type = frappe.conf.db_type
if not root_login and db_type == "mariadb":
root_login = "root"
elif not root_login and db_type == "postgres":
root_login = "postgres"
make_conf(
db_name,
site_config=site_config,
@ -159,8 +154,11 @@ def install_db(
)
frappe.flags.in_install_db = True
frappe.flags.root_login = root_login
frappe.flags.root_password = root_password
if root_login:
frappe.flags.root_login = root_login
if root_password:
frappe.flags.root_password = root_password
if setup:
setup_database(force, verbose, mariadb_user_host_login_scope)

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}