30 lines
859 B
Python
30 lines
859 B
Python
|
|
"""initial schema part 5: hardening and partial indexes
|
||
|
|
|
||
|
|
Revision ID: 202602260005
|
||
|
|
Revises: 202602260004
|
||
|
|
Create Date: 2026-02-26 20:14:00
|
||
|
|
"""
|
||
|
|
|
||
|
|
from typing import Sequence, Union
|
||
|
|
|
||
|
|
from alembic import op
|
||
|
|
|
||
|
|
revision: str = "202602260005"
|
||
|
|
down_revision: Union[str, Sequence[str], None] = "202602260004"
|
||
|
|
branch_labels: Union[str, Sequence[str], None] = None
|
||
|
|
depends_on: Union[str, Sequence[str], None] = None
|
||
|
|
|
||
|
|
|
||
|
|
def upgrade() -> None:
|
||
|
|
op.execute(
|
||
|
|
"CREATE INDEX ix_inbox_messages_pending_recent ON inbox_messages (recipient_id, created_at DESC) WHERE status = 'pending'"
|
||
|
|
)
|
||
|
|
op.execute(
|
||
|
|
"CREATE INDEX ix_todos_pending_due ON todos (owner_id, due_at) WHERE status = 'pending'"
|
||
|
|
)
|
||
|
|
|
||
|
|
|
||
|
|
def downgrade() -> None:
|
||
|
|
op.execute("DROP INDEX IF EXISTS ix_todos_pending_due")
|
||
|
|
op.execute("DROP INDEX IF EXISTS ix_inbox_messages_pending_recent")
|