mirror of
https://github.com/RaisFast/raisfast.git
synced 2026-10-09 08:02:46 +00:00
feat(agent): per-user memory isolation — owner_id→user_id + user-scoped memory tiers
This commit is contained in:
@@ -1507,7 +1507,7 @@ CREATE INDEX IF NOT EXISTS idx_flow_trigger_flow ON flow_trigger(flow_id);
|
||||
CREATE TABLE IF NOT EXISTS ai_agents (
|
||||
id INTEGER PRIMARY KEY,
|
||||
tenant_id TEXT NOT NULL DEFAULT 'default',
|
||||
owner_id INTEGER,
|
||||
user_id INTEGER,
|
||||
name TEXT NOT NULL,
|
||||
system_prompt TEXT NOT NULL DEFAULT '',
|
||||
provider TEXT NOT NULL,
|
||||
@@ -1527,7 +1527,7 @@ CREATE TABLE IF NOT EXISTS ai_sessions (
|
||||
id INTEGER PRIMARY KEY,
|
||||
tenant_id TEXT NOT NULL DEFAULT 'default',
|
||||
agent_id INTEGER NOT NULL,
|
||||
owner_id INTEGER NOT NULL,
|
||||
user_id INTEGER NOT NULL,
|
||||
title TEXT NOT NULL DEFAULT '',
|
||||
status TEXT NOT NULL DEFAULT 'open',
|
||||
meta TEXT,
|
||||
@@ -1537,7 +1537,7 @@ CREATE TABLE IF NOT EXISTS ai_sessions (
|
||||
last_active_at TEXT NOT NULL DEFAULT (strftime('%Y-%m-%dT%H:%M:%SZ','now'))
|
||||
);
|
||||
CREATE INDEX IF NOT EXISTS idx_ai_sessions_tenant_agent ON ai_sessions(tenant_id, agent_id);
|
||||
CREATE INDEX IF NOT EXISTS idx_ai_sessions_owner_active ON ai_sessions(owner_id, last_active_at);
|
||||
CREATE INDEX IF NOT EXISTS idx_ai_sessions_owner_active ON ai_sessions(user_id, last_active_at);
|
||||
|
||||
CREATE TABLE IF NOT EXISTS ai_messages (
|
||||
id INTEGER PRIMARY KEY,
|
||||
@@ -1566,6 +1566,7 @@ CREATE TABLE IF NOT EXISTS ai_memories (
|
||||
id INTEGER PRIMARY KEY,
|
||||
tenant_id TEXT NOT NULL DEFAULT 'default',
|
||||
agent_id INTEGER NOT NULL,
|
||||
user_id BIGINT,
|
||||
session_id INTEGER,
|
||||
mem_key TEXT NOT NULL,
|
||||
content TEXT NOT NULL,
|
||||
@@ -1575,7 +1576,7 @@ CREATE TABLE IF NOT EXISTS ai_memories (
|
||||
pinned INTEGER NOT NULL DEFAULT 0,
|
||||
created_at TEXT NOT NULL DEFAULT (strftime('%Y-%m-%dT%H:%M:%SZ','now')),
|
||||
updated_at TEXT NOT NULL DEFAULT (strftime('%Y-%m-%dT%H:%M:%SZ','now')),
|
||||
UNIQUE (tenant_id, agent_id, mem_key)
|
||||
UNIQUE (tenant_id, agent_id, user_id, mem_key)
|
||||
);
|
||||
CREATE INDEX IF NOT EXISTS idx_ai_memories_agent_live ON ai_memories(agent_id, superseded_by);
|
||||
CREATE INDEX IF NOT EXISTS idx_ai_memories_agent_category ON ai_memories(agent_id, category);
|
||||
|
||||
Reference in New Issue
Block a user