Skip to content

Commit

Permalink
fix: 添加补丁兼容mysql5.7 TencentBlueKing#7625
Browse files Browse the repository at this point in the history
  • Loading branch information
huangpixu committed Dec 9, 2024
1 parent dbf1401 commit 434005a
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions config/default.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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

0 comments on commit 434005a

Please sign in to comment.