From 434005aae8708cfea4f2d95b9c40b5897943b842 Mon Sep 17 00:00:00 2001 From: huangpixu Date: Mon, 9 Dec 2024 16:14:24 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E6=B7=BB=E5=8A=A0=E8=A1=A5=E4=B8=81?= =?UTF-8?q?=E5=85=BC=E5=AE=B9mysql5.7=20#7625?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- config/default.py | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/config/default.py b/config/default.py index c96c6c133..320894e16 100644 --- a/config/default.py +++ b/config/default.py @@ -21,6 +21,8 @@ from blueapps.conf.default_settings import * # noqa from blueapps.conf.log import get_logging_config_dict from blueapps.opentelemetry.utils import inject_logging_trace_info +from django.db.backends.mysql.features import DatabaseFeatures +from django.utils.functional import cached_property from django.utils.translation import ugettext_lazy as _ from pipeline.celery.queues import ScalableQueues @@ -893,3 +895,19 @@ def check_engine_admin_permission(request, *args, **kwargs): if "BKAPP_SOPS_BROKER_URL" in os.environ: BROKER_URL = os.getenv("BKAPP_SOPS_BROKER_URL") print(f"BROKER_URL: {BROKER_URL}") + + +# 定义一个补丁来兼容 MySQL 5.7 + + +class PatchFeatures: + @cached_property + def minimum_database_version(self): + if self.connection.mysql_is_mariadb: + return (10, 4) + else: + return (5, 7) + + +# 将补丁应用到 DatabaseFeatures 中 +DatabaseFeatures.minimum_database_version = PatchFeatures.minimum_database_version