fix repeatable migrations

This commit is contained in:
Dusan Vojacek
2026-04-19 20:15:46 +02:00
parent 0c93f493a4
commit 22bca9cd9e
73 changed files with 22 additions and 15 deletions

View File

@@ -0,0 +1,20 @@
create or replace function ems.fn_modbus_written_command_ids(
p_site_id int,
p_lookback interval
)
returns jsonb
language sql
stable
as $fn$
select coalesce(
jsonb_agg(mc.id order by mc.written_at),
'[]'::jsonb
)
from ems.modbus_command mc
where mc.site_id = p_site_id
and mc.status = 'written'
and mc.written_at >= now() - p_lookback;
$fn$;
comment on function ems.fn_modbus_written_command_ids(int, interval) is
'ID written příkazů k ruční verifikaci (GET control/verify).';