feat: don't require editing MariaDB configuration to setup frappe (#25609)

* feat(db_requirements): Update db_manager.py

* feat(db-requirements): Update setup_db.py

* feat(db-requirements): Update setup_db.py

Don't add error message on top of check_compatible_versions() 's one

Co-authored-by: gavin <gavin18d@gmail.com>

---------

Co-authored-by: gavin <gavin18d@gmail.com>
This commit is contained in:
Thatoo 2024-03-26 14:19:22 +01:00 committed by GitHub
parent 7f4bcf37ce
commit ed01fc3b26
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 2 additions and 33 deletions

View file

@ -25,7 +25,7 @@ class DbManager:
def create_database(self, target):
if target in self.get_database_list():
self.drop_database(target)
self.db.sql(f"CREATE DATABASE `{target}`")
self.db.sql(f"CREATE DATABASE `{target}` CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci")
def drop_database(self, target):
self.db.sql_ddl(f"DROP DATABASE IF EXISTS `{target}`")

View file

@ -5,11 +5,6 @@ import click
import frappe
from frappe.database.db_manager import DbManager
REQUIRED_MARIADB_CONFIG = {
"character_set_server": "utf8mb4",
"collation_server": "utf8mb4_unicode_ci",
}
def get_mariadb_variables():
return frappe._dict(frappe.db.sql("show variables"))
@ -71,9 +66,7 @@ def bootstrap_database(verbose, source_sql=None):
import sys
frappe.connect()
if not check_database_settings():
print("Database settings do not match expected values; stopping database setup.")
sys.exit(1)
check_compatible_versions()
import_db_from_sql(source_sql, verbose)
@ -105,30 +98,6 @@ def import_db_from_sql(source_sql=None, verbose=False):
print("Imported from database %s" % source_sql)
def check_database_settings():
check_compatible_versions()
# Check each expected value vs. actuals:
mariadb_variables = get_mariadb_variables()
result = True
for key, expected_value in REQUIRED_MARIADB_CONFIG.items():
if mariadb_variables.get(key) != expected_value:
print(f"For key {key}. Expected value {expected_value}, found value {mariadb_variables.get(key)}")
result = False
if not result:
print(
(
"{sep2}Creation of your site - {site} failed because MariaDB is not properly {sep}"
"configured.{sep2}"
"Please verify the above settings in MariaDB's my.cnf. Restart MariaDB.{sep}"
"And then run `bench new-site {site}` again.{sep2}"
).format(site=frappe.local.site, sep2="\n\n", sep="\n")
)
return result
def check_compatible_versions():
try:
version = get_mariadb_version()