Files
zarinpal-analytics-backend/migrations/000003_ai_summary_refresh.sql

14 lines
592 B
SQL

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;