     tag.name tag_name,
     handover_relation.direction, 
     array_agg(
-        (existence.exists, date_part('epoch', existence.timestamp))
+        (existence.exists, date_part('epoch', existence.timestamp))::gis.existence_change
     ) existence
 FROM gis.handover_relation
 JOIN directory.entity src_et ON src_et.id = handover_relation.source_entity_id


GRANT ALL ON TABLE gis.handover_relation TO minerva_admin;
GRANT SELECT ON TABLE gis.handover_relation TO minerva;

CREATE OR REPLACE VIEW gis.handover_relation_existence AS
SELECT

		tag.name,
		handover_relation.direction ) t
    LEFT JOIN gis.handoverrelation_tags ON handoverrelation_tags.entity_id = t.handover_id
$BODY$
  LANGUAGE sql STABLE
  COST 100
