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 @@
-- začátek aktuálního (+offset) 15min slotu v Europe/Prague jako timestamptz (UTC instants)
create or replace function ems.fn_planning_slot_boundary_prague(p_offset_slots int default 0)
returns timestamptz
language sql
stable
as $fn$
select (
(date_trunc('day', loc.ts)
+ make_interval(
hours => extract(hour from loc.ts)::int,
mins => (floor(extract(minute from loc.ts) / 15) * 15)::int
)
)::timestamp at time zone 'Europe/Prague'
) + make_interval(mins => coalesce(p_offset_slots, 0) * 15)
from (select now() at time zone 'Europe/Prague' as ts) loc;
$fn$;
comment on function ems.fn_planning_slot_boundary_prague(int) is
'Začátek 15min slotu v časové zóně site provozu (Europe/Prague floor); offset v násobcích 15 min.';