From 3f0e9c334741dc40171d85d272aaf93b148266b7 Mon Sep 17 00:00:00 2001 From: yumoqing Date: Sat, 15 Aug 2026 02:04:42 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E5=BB=BA=E8=A1=A8=E8=84=9A=E6=9C=AC?= =?UTF-8?q?=E8=A1=A5appbase=20params=E8=A1=A8=E5=B9=82=E7=AD=89=E5=BB=BA?= =?UTF-8?q?=E8=A1=A8+workspace=5Fbase=E9=BB=98=E8=AE=A4=E5=8F=82=E6=95=B0?= =?UTF-8?q?=EF=BC=8C=E4=BF=AEparams=E8=A1=A8=E7=BC=BA=E5=A4=B1bug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- scripts/create_tables.py | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/scripts/create_tables.py b/scripts/create_tables.py index d0abafe..661df3d 100644 --- a/scripts/create_tables.py +++ b/scripts/create_tables.py @@ -22,6 +22,21 @@ from ahserver.globalEnv import initEnv TABLE_MODULES = ['product_management', 'discount', 'pricing', 'unipay', 'smssend'] +# appbase 系统级配置表(幂等建表 + 默认参数,不 DROP 以免清空运行时数据) +_PARAMS_DDL = """ +CREATE TABLE IF NOT EXISTS params ( + `id` VARCHAR(32) comment 'id', + `params_name` VARCHAR(255) comment '参数名称', + `params_value` VARCHAR(4000) comment '参数值', + primary key(id) +) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci engine=innodb comment '系统参数表'; +""" + +_PARAMS_INIT = [ + ("workspace_base", "/d/pipeline/workspaces"), +] + + def split_ddl(ddl): """按分号分割 DDL,跳过注释行和空语句。""" stmts = [] @@ -57,6 +72,19 @@ async def main(): n += 1 print(f' tables: {mod} created ({n} statements)') + # appbase params 表幂等建表 + 默认参数 + try: + await sor.execute(_PARAMS_DDL, {}) + for pname, pval in _PARAMS_INIT: + await sor.execute( + "INSERT INTO params (id, params_name, params_value) " + "VALUES (${id}$, ${n}$, ${v}$) " + "ON DUPLICATE KEY UPDATE params_value=${v}$", + {"id": pname, "n": pname, "v": pval}) + print(' tables: appbase params ensured (workspace_base)') + except Exception as e: + print(f' WARN: appbase params ensure failed: {e}') + if __name__ == '__main__': asyncio.run(main())