对于表结构进中二进制值进行修正,避免建表时语法错误
This commit is contained in:
parent
0e5c49b138
commit
83cdd05f3b
@ -18,6 +18,7 @@ def load_config(config_path="config.yaml"):
|
|||||||
config = yaml.safe_load(file)
|
config = yaml.safe_load(file)
|
||||||
return config
|
return config
|
||||||
|
|
||||||
|
|
||||||
# 配置日志
|
# 配置日志
|
||||||
def setup_logging(config_level, log_file='migration.log', file_mode='a'):
|
def setup_logging(config_level, log_file='migration.log', file_mode='a'):
|
||||||
numeric_level = getattr(logging, config_level.upper(), None)
|
numeric_level = getattr(logging, config_level.upper(), None)
|
||||||
@ -124,12 +125,7 @@ class DBMigrator:
|
|||||||
return False
|
return False
|
||||||
|
|
||||||
def correct_bit_default_value(self, sql):
|
def correct_bit_default_value(self, sql):
|
||||||
"""
|
corrected_sql = sql.replace("bit(1) DEFAULT '0'", "bit(1) DEFAULT b'0'")
|
||||||
检查并修正BIT(1)类型字段的默认值表示。
|
|
||||||
将错误的表示('0'/'1')转换为正确的二进制表示(b'0'/b'1')。
|
|
||||||
"""
|
|
||||||
# 使用正则表达式匹配并修正BIT(1)类型字段的默认值表示
|
|
||||||
corrected_sql = re.sub(r"BIT$1$( NOT NULL)? DEFAULT '([01])'", r"BIT(1)\1 DEFAULT b'\2'", sql)
|
|
||||||
return corrected_sql
|
return corrected_sql
|
||||||
|
|
||||||
def migrate_table_data(self, table):
|
def migrate_table_data(self, table):
|
||||||
|
Loading…
x
Reference in New Issue
Block a user