feat: add platform usage worker

This commit is contained in:
Codex
2026-06-30 20:00:14 +08:00
parent 686b3609cf
commit ff2b0a83ee
16 changed files with 1002 additions and 17 deletions

View File

@@ -0,0 +1,6 @@
create unique index if not exists idx_tenant_usage_records_worker_unique
on public.tenant_usage_records(tenant_id, metric_key, period_start, period_end)
where metadata->>'source' = 'platform_usage_worker';
comment on index public.idx_tenant_usage_records_worker_unique is
'Ensures platform usage worker can upsert one authoritative record per tenant, metric and period while manual adjustments remain append-only.';