fix lfywlay migration
This commit is contained in:
21
db/views/R__040_vw_modbus_last_verified.sql
Normal file
21
db/views/R__040_vw_modbus_last_verified.sql
Normal file
@@ -0,0 +1,21 @@
|
||||
-- poslední úspěšně ověřený zápis per (site, asset, register)
|
||||
|
||||
drop view if exists ems.vw_modbus_last_verified;
|
||||
|
||||
create view ems.vw_modbus_last_verified as
|
||||
select distinct on (mc.site_id, mc.asset_type, mc.asset_id, mc.register)
|
||||
mc.id,
|
||||
mc.site_id,
|
||||
mc.asset_type,
|
||||
mc.asset_id,
|
||||
mc.register,
|
||||
mc.value_verified,
|
||||
mc.verified_at,
|
||||
mc.status
|
||||
from ems.modbus_command mc
|
||||
where mc.status = 'verified'
|
||||
and mc.value_verified is not null
|
||||
order by mc.site_id, mc.asset_type, mc.asset_id, mc.register, mc.verified_at desc nulls last, mc.id desc;
|
||||
|
||||
comment on view ems.vw_modbus_last_verified is
|
||||
'DISTINCT ON (register) poslední verified řádek pro ověření / mapu registrů.';
|
||||
Reference in New Issue
Block a user