feat: auto-create pipeline_user_memory table on startup
This commit is contained in:
parent
2d6709ee33
commit
cd9208cbf4
@ -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
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user