CREATE OR REPLACE VIEW gestion.v_interventions AS (
	SELECT e.geom, i.*
	FROM maintenance_intervention AS i, core_topology AS e
	WHERE i.topology_id = e.id
	AND i.deleted = FALSE
);

CREATE OR REPLACE VIEW gestion.v_projects AS (
	SELECT ST_Union(t.geom) AS geom_chantier, s.*
	FROM maintenance_intervention AS t, maintenance_project AS s
	WHERE t.project_id = s.id
	GROUP BY t.project_id, s.id
);

CREATE OR REPLACE VIEW gestion.v_interventions AS (
	SELECT e.geom, i.*
	FROM maintenance_intervention AS i, core_topology AS e
	WHERE i.topology_id = e.id
	AND i.deleted = FALSE
);

CREATE OR REPLACE VIEW gestion.v_projects AS (
	SELECT ST_Union(t.geom) AS geom_chantier, s.*
	FROM v_interventions AS t, maintenance_project AS s
	WHERE t.project_id = s.id
	GROUP BY t.project_id, s.id
);

Fix view sql v interventions
Fix view sql v interventions
