-- Part 9: claim-path indexes
-- Compose after: content/series/durable-work-postgres/source/schema.sql.
-- These indexes support the claim, bucketed claim, stale lease, and dashboard paths.

CREATE INDEX idx_inbox_claim_ready
  ON inbox (available_at, created_at, id)
  WHERE status = 'pending';

CREATE INDEX idx_inbox_bucket_claim_ready
  ON inbox (partition_bucket, available_at, created_at, id)
  WHERE status = 'pending';

CREATE INDEX idx_inbox_processing_expiry
  ON inbox (lease_expires_at, id)
  WHERE status = 'processing';

CREATE INDEX idx_inbox_status_created
  ON inbox (status, created_at);
