fix: preserve typed growth report revisions

This commit is contained in:
2026-08-21 00:43:31 +03:30
parent 49084ea577
commit dd0ae15a95
3 changed files with 29 additions and 11 deletions

View File

@@ -14,7 +14,7 @@ CREATE TABLE IF NOT EXISTS growth_reports (
prompt_version text NOT NULL,
schema_version text NOT NULL,
model text NOT NULL,
deterministic_evidence jsonb NOT NULL DEFAULT '{}'::jsonb,
deterministic_evidence jsonb,
ai_response jsonb,
failure_code text,
input_tokens bigint NOT NULL DEFAULT 0 CHECK (input_tokens >= 0),
@@ -36,7 +36,7 @@ CREATE UNIQUE INDEX IF NOT EXISTS growth_reports_daily_merchant_refresh_idx
WHERE manual_refresh = true;
-- statement-break
CREATE INDEX IF NOT EXISTS growth_reports_scope_latest_idx
ON growth_reports (merchant_id, terminal_id, created_at DESC);
ON growth_reports (merchant_id, terminal_id, revision DESC, created_at DESC);
-- statement-break
CREATE INDEX IF NOT EXISTS growth_reports_pending_idx
ON growth_reports (created_at)