create unique index if not exists idx_student_followups_auto_supervision_key
  on public.tenant_student_followups(tenant_id, (metadata->'autoSupervision'->>'idempotencyKey'))
  where metadata->'autoSupervision'->>'idempotencyKey' is not null;

create index if not exists idx_student_followups_auto_supervision
  on public.tenant_student_followups(tenant_id, student_user_id, created_at desc)
  where metadata->'autoSupervision' is not null;

create index if not exists idx_answer_records_tenant_user_answered
  on public.answer_records(tenant_id, user_id, answered_at desc);

create index if not exists idx_practice_reports_tenant_user_submitted
  on public.practice_session_reports(tenant_id, user_id, submitted_at desc);
