From cd9208cbf458dea1b22181baeb2745c582c4f055 Mon Sep 17 00:00:00 2001 From: ymq Date: Mon, 10 Aug 2026 11:10:53 +0800 Subject: [PATCH] feat: auto-create pipeline_user_memory table on startup --- pipeline_service/init.py | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/pipeline_service/init.py b/pipeline_service/init.py index 4d2b24b..9d2f9dd 100644 --- a/pipeline_service/init.py +++ b/pipeline_service/init.py @@ -617,5 +617,28 @@ def load_pipeline_service(): add_startup(_pm_poller) + # v2 DDL auto-init: create pipeline_user_memory table at startup + async def _init_v2_tables(app): + from sqlor.dbpools import DBPools as _DBP2 + from appPublic.log import debug as _debug + try: + _db = _DBP2() + async with _db.sqlorContext("pipeline") as sor: + await sor.sqlExe( + "CREATE TABLE IF NOT EXISTS pipeline_user_memory (" + "id varchar(32) NOT NULL, memory_key varchar(64) NOT NULL," + "content text NOT NULL, category varchar(32) NOT NULL DEFAULT 'memory'," + "priority int NOT NULL DEFAULT 0, access_count int NOT NULL DEFAULT 0," + "created_at datetime NOT NULL DEFAULT CURRENT_TIMESTAMP," + "updated_at datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP," + "PRIMARY KEY (id), UNIQUE KEY uk_memory (memory_key, category)," + "KEY idx_category_priority (category, priority)" + ") ENGINE=InnoDB DEFAULT CHARSET=utf8mb4", {}) + _debug("pipeline_user_memory table ready") + except Exception as e: + _debug(f"pipeline_user_memory init: {e}") + + add_startup(_init_v2_tables) + debug(f"[{MODULE_NAME}] v{MODULE_VERSION} loaded — pipeline engine with role-agent + question loop") return True