From b7c6d8b8fbc71d2ccfa9170db525712e140e7601 Mon Sep 17 00:00:00 2001 From: yumoqing Date: Thu, 10 Sep 2026 17:09:46 +0800 Subject: [PATCH] =?UTF-8?q?feat(migration):=20m0023=20pipeline=5Fuser=5Fme?= =?UTF-8?q?mory=20=E5=A4=9A=E7=A7=9F=E6=88=B7(=E5=8A=A0org=5Fid/user=5Fid?= =?UTF-8?q?=E5=88=97+=E5=AD=98=E9=87=8Fkey=E9=87=8D=E7=AE=97+=E5=BD=92?= =?UTF-8?q?=E5=B1=9E=E7=B4=A2=E5=BC=95)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../m0023_pipeline_user_memory_multitenant.json | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) create mode 100644 deploy/migrations/m0023_pipeline_user_memory_multitenant.json diff --git a/deploy/migrations/m0023_pipeline_user_memory_multitenant.json b/deploy/migrations/m0023_pipeline_user_memory_multitenant.json new file mode 100644 index 0000000..d1c461b --- /dev/null +++ b/deploy/migrations/m0023_pipeline_user_memory_multitenant.json @@ -0,0 +1,16 @@ +{ + "id": "m0023", + "title": "pipeline_user_memory 多租户隔离:加 org_id/user_id 归属列 + 存量 memory_key 重算(新 key 掺租户/作用域维度,防跨租户唯一键碰撞)+ 归属查询索引", + "backup_tables": ["pipeline_user_memory"], + "up": [ + {"op": "sql", "sql": "ALTER TABLE pipeline_user_memory ADD COLUMN org_id varchar(32) NOT NULL DEFAULT '' AFTER scope_id"}, + {"op": "sql", "sql": "ALTER TABLE pipeline_user_memory ADD COLUMN user_id varchar(32) NOT NULL DEFAULT '' AFTER org_id"}, + {"op": "sql", "sql": "UPDATE pipeline_user_memory SET memory_key = LEFT(MD5(CONCAT(content, '|org=', org_id, '|user=', user_id, '|scope=', scope, '|sid=', scope_id)), 16)"}, + {"op": "sql", "sql": "CREATE INDEX idx_memory_org_user ON pipeline_user_memory (org_id, user_id)"} + ], + "down": [ + {"op": "sql", "sql": "UPDATE pipeline_user_memory SET memory_key = LEFT(MD5(content), 16)"}, + {"op": "sql", "sql": "ALTER TABLE pipeline_user_memory DROP COLUMN user_id"}, + {"op": "sql", "sql": "ALTER TABLE pipeline_user_memory DROP COLUMN org_id"} + ] +}