This commit is contained in:
Classic298 2026-09-30 19:03:50 +04:00 • committed by GitHub
commit b039fe2261
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -0,0 +1,34 @@
"""add pending knowledge files index
Revision ID: a7e2c4f91b08
Revises: d4c1a8e37b62
Create Date: 2026-09-14 13:42:18.905331
"""
from collections.abc import Sequence
import sqlalchemy as sa
from alembic import op
# revision identifiers, used by Alembic.
revision: str = 'a7e2c4f91b08'
down_revision: str | None = 'd4c1a8e37b62'
branch_labels: str | Sequence[str] | None = None
depends_on: str | Sequence[str] | None = None
def upgrade() -> None:
# SQLite does not fold bound parameters when matching an expression index, so it could never use this one.
if op.get_bind().dialect.name == 'postgresql':
op.create_index(
'file_pending_knowledge_idx',
'file',
[sa.text("((meta -> 'data') ->> 'knowledge_id')")],
postgresql_where=sa.text("(data ->> 'status') IN ('pending', 'processing')"),
)
def downgrade() -> None:
if op.get_bind().dialect.name == 'postgresql':
op.drop_index('file_pending_knowledge_idx', table_name='file')