diff --git a/src/models.py b/src/models.py index ae5c08c..5fc1fe3 100644 --- a/src/models.py +++ b/src/models.py @@ -175,6 +175,22 @@ async def _create_tables(pool: aiomysql.Pool): ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 """) + # V2.0.3 迁移:为旧表补充波动测试参数字段 + for col, col_def in [ + ("FarTol", "INT DEFAULT 0 COMMENT '最远容差 cm'"), + ("NearTol", "INT DEFAULT 0 COMMENT '最近容差 cm'"), + ("StepTol", "INT DEFAULT 0 COMMENT '步进容差 cm'"), + ("BackForth", "INT DEFAULT 0 COMMENT '来回次数'"), + ("NearStay", "INT DEFAULT 0 COMMENT '最近停留时间 ms'"), + ("FarStay", "INT DEFAULT 0 COMMENT '最远停留时间 ms'"), + ]: + try: + await cur.execute( + f"ALTER TABLE `tb_fixture_param` ADD COLUMN `{col}` {col_def}" + ) + except Exception: + pass # 列已存在,忽略 + # 7. 车检器测试基准参数表 await cur.execute(""" CREATE TABLE IF NOT EXISTS `tb_vechicle_base_test` (