修复 mysql 初始化脚本转 dm8 失效的问题

This commit is contained in:
chenbowen
2025-07-01 14:59:11 +08:00
committed by chenbowen
parent 6129e91ab5
commit 4973950e01
18 changed files with 1426 additions and 977 deletions

View File

@@ -45,7 +45,9 @@ def load_and_clean(sql_file: str) -> str:
("b'1'", "'1'"),
)
content = open(sql_file).read()
# 指定 utf-8 编码并忽略无法解码的字节
with open(sql_file, encoding="utf-8", errors="ignore") as f:
content = f.read()
for replace_pair in REPLACE_PAIR_LIST:
content = content.replace(*replace_pair)
content = re.sub(r"ENGINE.*COMMENT", "COMMENT", content)
@@ -701,7 +703,8 @@ class DM8Convertor(Convertor):
def generate_column(col):
name = col["name"].lower()
if name == "id":
return "id bigint NOT NULL PRIMARY KEY IDENTITY"
# 默认不生成自增,使用分布式 Id
return "id bigint NOT NULL PRIMARY KEY "
type = col["type"].lower()
full_type = self.translate_type(type, col["size"])