implmentace plan guardu
Some checks failed
CI and deploy / migration-check (push) Failing after 17s
CI and deploy / deploy (push) Has been skipped

This commit is contained in:
Dusan Vojacek
2026-04-19 23:10:25 +02:00
parent d8221e3169
commit e3776226a4
9 changed files with 369 additions and 7 deletions

View File

@@ -0,0 +1,18 @@
-- Jednorázové potvrzení odeslání fatálního Discord alertu plán vs. skutečnost (deduplikace po slotu).
create table ems.plan_fatal_deviation_sent (
site_id int not null references ems.site (id),
interval_start timestamptz not null,
reason_code text not null,
sent_at timestamptz not null default now(),
primary key (site_id, interval_start)
);
create index idx_plan_fatal_deviation_sent_sent_at
on ems.plan_fatal_deviation_sent (sent_at desc);
comment on table ems.plan_fatal_deviation_sent is
'Backend job po uzavření 15min slotu: při fatální odchylce grid plán vs. audit jednou pošle Discord a zapíše řádek (PK site_id + interval_start).';
comment on column ems.plan_fatal_deviation_sent.reason_code is
'Kód z ems.fn_plan_actual_slot_guard_site (např. GRID_SIGN_MISMATCH, GRID_EXPORT_SPIKE).';