fix: keep growth analysis available per terminal

This commit is contained in:
2026-08-21 02:57:46 +03:30
parent 7951664d08
commit e6afaa7a10
11 changed files with 180 additions and 45 deletions

View File

@@ -0,0 +1,13 @@
DROP INDEX IF EXISTS growth_reports_daily_merchant_refresh_idx;
-- statement-break
CREATE INDEX IF NOT EXISTS growth_reports_scope_refresh_day_idx
ON growth_reports (merchant_id, terminal_source_key, tehran_refresh_day, created_at DESC)
WHERE manual_refresh = true;
-- The application serializes scope-specific refresh decisions with a PostgreSQL
-- advisory transaction lock. A refresh consumes the daily slot only after the
-- requested scope has a persisted READY report with AI copy.
-- statement-break
INSERT INTO schema_migrations(version) VALUES (3) ON CONFLICT DO NOTHING;