From 0b3cf1d83e1a7e3a204696cc92c623407e90b8e5 Mon Sep 17 00:00:00 2001 From: Denis Rouzaud Date: Mon, 11 Nov 2024 14:35:57 +0100 Subject: [PATCH] fix view --- datamodel/app/vw_validation.sql | 6 +++--- datamodel/changelogs/0102/0101_02_control.sql | 8 ++++---- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/datamodel/app/vw_validation.sql b/datamodel/app/vw_validation.sql index dfdd3eda..889ee4e0 100644 --- a/datamodel/app/vw_validation.sql +++ b/datamodel/app/vw_validation.sql @@ -6,9 +6,9 @@ CREATE OR REPLACE VIEW signalo_app.vw_validation AS greatest(su._last_modification_date, a._last_modification_date, f._last_modification_date, si._last_modification_date) AS last_modification_date, su.needs_validation or a.needs_validation or f.needs_validation or si.needs_validation AS needs_validation FROM signalo_db.support su - LEFT JOIN (SELECT id, fk_support, needs_validation, MAX(_last_modification_date) OVER (PARTITION BY fk_support) AS _last_modification_date FROM signalo_db.azimut ) a ON a.fk_support = su.id - LEFT JOIN (SELECT id, fk_azimut, needs_validation, MAX(_last_modification_date) OVER (PARTITION BY fk_azimut) AS _last_modification_date FROM signalo_db.frame) f ON f.fk_azimut = a.id - LEFT JOIN (SELECT id, fk_frame, needs_validation, MAX(_last_modification_date) OVER (PARTITION BY fk_frame) AS _last_modification_date FROM signalo_db.sign) si ON si.fk_frame = f.id; + LEFT JOIN (SELECT id, fk_support, needs_validation, MAX(_last_modification_date) OVER (PARTITION BY fk_support ORDER BY needs_validation DESC NULLS LAST) AS _last_modification_date FROM signalo_db.azimut ) a ON a.fk_support = su.id + LEFT JOIN (SELECT id, fk_azimut, needs_validation, MAX(_last_modification_date) OVER (PARTITION BY fk_azimut ORDER BY needs_validation DESC NULLS LAST) AS _last_modification_date FROM signalo_db.frame) f ON f.fk_azimut = a.id + LEFT JOIN (SELECT id, fk_frame, needs_validation, MAX(_last_modification_date) OVER (PARTITION BY fk_frame ORDER BY needs_validation DESC NULLS LAST) AS _last_modification_date FROM signalo_db.sign) si ON si.fk_frame = f.id; CREATE FUNCTION signalo_app.ft_validation_update() RETURNS trigger LANGUAGE plpgsql diff --git a/datamodel/changelogs/0102/0101_02_control.sql b/datamodel/changelogs/0102/0101_02_control.sql index e0823521..4dbe521d 100644 --- a/datamodel/changelogs/0102/0101_02_control.sql +++ b/datamodel/changelogs/0102/0101_02_control.sql @@ -3,10 +3,10 @@ ALTER TABLE signalo_db.azimut DROP COLUMN _edited; ALTER TABLE signalo_db.frame DROP COLUMN _edited; ALTER TABLE signalo_db.sign DROP COLUMN _edited; -ALTER TABLE signalo_db.support ADD COLUMN needs_validation boolean default false; -ALTER TABLE signalo_db.azimut ADD COLUMN needs_validation boolean default false; -ALTER TABLE signalo_db.frame ADD COLUMN needs_validation boolean default false; -ALTER TABLE signalo_db.sign ADD COLUMN needs_validation boolean default false; +ALTER TABLE signalo_db.support ADD COLUMN needs_validation boolean not null default false; +ALTER TABLE signalo_db.azimut ADD COLUMN needs_validation boolean not null default false; +ALTER TABLE signalo_db.frame ADD COLUMN needs_validation boolean not null default false; +ALTER TABLE signalo_db.sign ADD COLUMN needs_validation boolean not null default false; ALTER TABLE signalo_db.support ADD COLUMN _last_modification_platform text default null; ALTER TABLE signalo_db.azimut ADD COLUMN _last_modification_platform text default null;