Files
FabledScribe/alembic/versions/0007_add_title_and_updated_at_indexes.py
T
bvandeusen db01106714 Backend efficiency & consistency pass
- Rewrite get_all_tags() with SQL unnest instead of loading all notes
- Consolidate convert_note_to_task/convert_task_to_note to single-session ops
- Add search_notes_for_context() with single OR-keyword query for build_context()
- Drop selectinload from list_conversations(), use correlated subquery for message_count
- Add set_settings_batch() for single-transaction multi-setting upserts
- Extract get_installed_models() shared helper into services/llm.py
- Delete services/tasks.py pass-through wrapper; routes/tasks.py imports from services.notes
- Add B-tree indexes on notes.title and conversations.updated_at (migration 0007)
- Add logging to services/notes.py, services/chat.py, services/settings.py
- Safe Conversation.to_dict() when messages relationship is not loaded

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-11 08:27:11 -05:00

24 lines
571 B
Python

"""add title and updated_at indexes
Revision ID: 0007
Revises: 0006
Create Date: 2026-02-11 00:00:00.000000
"""
from alembic import op
revision = "0007"
down_revision = "0006"
branch_labels = None
depends_on = None
def upgrade() -> None:
op.execute("CREATE INDEX IF NOT EXISTS ix_notes_title ON notes (title)")
op.execute("CREATE INDEX IF NOT EXISTS ix_conversations_updated_at ON conversations (updated_at)")
def downgrade() -> None:
op.execute("DROP INDEX IF EXISTS ix_notes_title")
op.execute("DROP INDEX IF EXISTS ix_conversations_updated_at")