Skip to content

Commit

Permalink
fix: 添加补丁兼容mysql5.7 TencentBlueKing#1464
Browse files Browse the repository at this point in the history
  • Loading branch information
huangpixu committed Jan 3, 2025
1 parent ce6f1a6 commit 8931e5a
Showing 1 changed file with 19 additions and 1 deletion.
20 changes: 19 additions & 1 deletion config/default.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,9 @@
from blueapps.opentelemetry.utils import inject_logging_trace_info
from django.http import HttpResponseRedirect
from django.urls import reverse
from django.db.backends.mysql.features import DatabaseFeatures
from django.utils.functional import cached_property


from config import (
APP_CODE,
Expand Down Expand Up @@ -376,7 +379,9 @@ def _(s):
if IS_USE_REDIS:
CACHE_BACKEND_TYPE = os.environ.get("CACHE_BACKEND_TYPE", "RedisCache")
REDIS_PORT = os.environ.get("BKAPP_REDIS_PORT", 6379)
REDIS_PASSWORD = os.environ.get("BKAPP_REDIS_PASSWORD", "") # 密码中不能包括敏感字符,例如":"
REDIS_PASSWORD = os.environ.get(
"BKAPP_REDIS_PASSWORD", ""
) # 密码中不能包括敏感字符,例如":"
REDIS_SERVICE_NAME = os.environ.get("BKAPP_REDIS_SERVICE_NAME", "mymaster")
REDIS_MODE = os.environ.get("BKAPP_REDIS_MODE", "single")
REDIS_DB = os.environ.get("BKAPP_REDIS_DB", 0)
Expand Down Expand Up @@ -983,3 +988,16 @@ def redirect_func(request):
"BKAPP_QW_WEB_HOOK_URL",
"https://qyapi.weixin.qq.com/cgi-bin/webhook/send?key={}",
)


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

0 comments on commit 8931e5a

Please sign in to comment.