- AW-1: Add composite index on calendar_members(user_id, status) for the hot shared-calendar polling query - AS-6: Add composite index on ntfy_sent(user_id, sent_at) for dedup lookups - AW-5: Combine get_user_permission into single LEFT JOIN query instead of 2 sequential queries (called twice per event edit) - AC-5: Batch cascade_on_disconnect — single GROUP BY + bulk UPDATE instead of N per-calendar checks when a connection is severed - AW-6: Collapse admin dashboard 5 COUNT queries into single conditional aggregation using COUNT().filter() - AC-3: Cache get_current_settings in request.state to avoid redundant queries when multiple dependencies need settings in the same request Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
30 lines
751 B
Python
30 lines
751 B
Python
"""Add composite indexes for calendar_members and ntfy_sent
|
|
|
|
Revision ID: 053
|
|
Revises: 052
|
|
"""
|
|
from alembic import op
|
|
|
|
revision = "053"
|
|
down_revision = "052"
|
|
|
|
|
|
def upgrade():
|
|
# AW-1: Hot query polled every 5s uses (user_id, status) together
|
|
op.create_index(
|
|
"ix_calendar_members_user_id_status",
|
|
"calendar_members",
|
|
["user_id", "status"],
|
|
)
|
|
# AS-6: Dedup lookup in notification dispatch uses (user_id, sent_at)
|
|
op.create_index(
|
|
"ix_ntfy_sent_user_id_sent_at",
|
|
"ntfy_sent",
|
|
["user_id", "sent_at"],
|
|
)
|
|
|
|
|
|
def downgrade():
|
|
op.drop_index("ix_ntfy_sent_user_id_sent_at", table_name="ntfy_sent")
|
|
op.drop_index("ix_calendar_members_user_id_status", table_name="calendar_members")
|