ALTER TABLE memories ADD COLUMN IF NOT EXISTS auth_scope VARCHAR(255) NOT NULL DEFAULT 'public'; CREATE INDEX IF NOT EXISTS idx_memories_auth_scope ON memories (auth_scope); CREATE INDEX IF NOT EXISTS idx_memories_auth_scope_agent ON memories (auth_scope, agent_id);