Files
gongxue-base/supabase/migrations/202606300010_points_risk_report_indexes.sql
2026-06-30 15:12:32 +08:00

14 lines
643 B
SQL

create index if not exists idx_score_events_tenant_created_user_negative
on public.user_score_events(tenant_id, created_at desc, user_id)
where points < 0;
create index if not exists idx_score_events_tenant_created_abs_points
on public.user_score_events(tenant_id, created_at desc, (abs(points)) desc);
create index if not exists idx_point_activity_claims_tenant_claimed_user
on public.user_point_activity_claims(tenant_id, claimed_at desc, user_id)
where status = 'claimed';
create index if not exists idx_point_exchange_orders_tenant_exchanged_user
on public.user_point_exchange_orders(tenant_id, exchanged_at desc, user_id);