diff --git a/backend/open_webui/migrations/versions/a749ab2aa953_add_memory_user_id_index.py b/backend/open_webui/migrations/versions/a749ab2aa953_add_memory_user_id_index.py index 6a54d8d27b..254d49f7bf 100644 --- a/backend/open_webui/migrations/versions/a749ab2aa953_add_memory_user_id_index.py +++ b/backend/open_webui/migrations/versions/a749ab2aa953_add_memory_user_id_index.py @@ -7,7 +7,6 @@ Create Date: 2026-04-17 00:00:00.000000 """ from alembic import op -import sqlalchemy as sa revision = 'a749ab2aa953' down_revision = 'c1d2e3f4a5b6' diff --git a/backend/open_webui/models/memories.py b/backend/open_webui/models/memories.py index 1ec52eeb6a..5de250c1fb 100644 --- a/backend/open_webui/models/memories.py +++ b/backend/open_webui/models/memories.py @@ -6,7 +6,7 @@ from sqlalchemy import select, delete from sqlalchemy.ext.asyncio import AsyncSession from open_webui.internal.db import Base, get_async_db_context from pydantic import BaseModel, ConfigDict -from sqlalchemy import BigInteger, Column, String, Text +from sqlalchemy import BigInteger, Column, Index, String, Text #################### # Memory DB Schema @@ -19,11 +19,15 @@ class Memory(Base): __tablename__ = 'memory' id = Column(String, primary_key=True, unique=True) - user_id = Column(String, index=True) + user_id = Column(String) content = Column(Text) updated_at = Column(BigInteger) created_at = Column(BigInteger) + __table_args__ = ( + Index('memory_user_id_idx', 'user_id'), + ) + class MemoryModel(BaseModel): id: str