-- Kanban: composite partial index for active task queries by residence with due date ordering
CREATE INDEX IF NOT EXISTS idx_task_kanban_query
    ON task_task (residence_id, next_due_date, due_date)
    WHERE is_cancelled = false AND is_archived = false;

-- Notifications: partial index for unread count (hot query)
CREATE INDEX IF NOT EXISTS idx_notification_user_unread
    ON notifications_notification (user_id, read)
    WHERE read = false;

-- Documents: partial index for active documents by residence
CREATE INDEX IF NOT EXISTS idx_document_residence_active
    ON documents_document (residence_id, is_active)
    WHERE is_active = true;
