create unique index if not exists idx_coupon_redemptions_user_coupon_once
  on public.coupon_redemptions(tenant_id, user_id, coupon_id)
  where coupon_id is not null;

create index if not exists idx_coupon_redemptions_order_user
  on public.coupon_redemptions(tenant_id, order_id, user_id)
  where order_id is not null;

create index if not exists idx_payments_order_updated
  on public.payments(tenant_id, order_id, updated_at desc);

create index if not exists idx_order_items_order
  on public.order_items(tenant_id, order_id);
