Files
replypier/backend/alembic/versions/idx_kq_org_status_001.py
T
WangShen007 977783c126 build: 打通 FastAPI 与 Vue 最小工程、依赖与数据库连接
后端入口、配置、Redis 与 Alembic 迁移就位;前端 Vite 工程可安装可构建。
2026-09-22 20:15:00 +08:00

36 lines
1.2 KiB
Python

"""Index knowledge_queue by organization and status
The plan's source limit now counts the crawls still queued or running, so
every file upload and URL add reads this table. It had no index beyond the
primary key and priority, and nothing purges completed rows, so that read
was a sequential scan of every tenant's history.
Revision ID: idx_kq_org_status_001
Revises: add_mcp_usage_guidance_001
Create Date: 2026-09-18
"""
from typing import Sequence, Union
from alembic import op
# revision identifiers, used by Alembic.
# Keep revision ids under 32 characters: alembic_version.version_num is
# varchar(32), and a longer id upgrades the schema then fails to record
# itself, so every later start retries and crashes.
revision: str = 'idx_kq_org_status_001'
down_revision: Union[str, None] = 'add_mcp_usage_guidance_001'
branch_labels: Union[str, Sequence[str], None] = None
depends_on: Union[str, Sequence[str], None] = None
INDEX_NAME = 'ix_knowledge_queue_org_status'
def upgrade() -> None:
op.create_index(
INDEX_NAME, 'knowledge_queue', ['organization_id', 'status'], unique=False
)
def downgrade() -> None:
op.drop_index(INDEX_NAME, table_name='knowledge_queue')