There was an error while loading. Please reload this page.
2 parents 2e4d7dd + e0ca047 commit 276e761Copy full SHA for 276e761
1 file changed
migrations/001_alert_reports_unique_report_number.sql
@@ -0,0 +1,11 @@
1
+-- Prevent duplicate alert_reports rows when concurrent scheduler ticks
2
+-- or manual route invocations race on the same report_number.
3
+-- Apply manually on production after deduping existing rows, e.g.:
4
+--
5
+-- DELETE FROM alert_reports a
6
+-- USING alert_reports b
7
+-- WHERE a.id < b.id
8
+-- AND a.report_number = b.report_number;
9
10
+ALTER TABLE alert_reports
11
+ ADD CONSTRAINT alert_reports_report_number_key UNIQUE (report_number);
0 commit comments