       END IF;
     END IF;
   END IF;
+  IF (NEW.ldName != OLD.ldName
+      OR NEW.modifiedDate != OLD.modifiedDate
+      OR NEW.ownerId != NEW.ownerId) THEN
+    UPDATE wp4_table SET need_update=TRUE WHERE local_id = NEW.uid;
+  END IF;
 END|
+
+DROP TRIGGER IF EXISTS on_ldata_insert |
+CREATE TRIGGER on_ldata_insert
+AFTER INSERT ON ldata_table
+FOR EACH ROW BEGIN
+  INSERT INTO wp4_table (local_id, global_id) VALUES(NEW.uid, UUID());
+END|
+
 
 -- DROP TRIGGER IF EXISTS on_pdri_incert |
 -- CREATE TRIGGER on_pdri_incert


DROP TRIGGER IF EXISTS on_ldata_update |
CREATE TRIGGER on_ldata_update
BEFORE UPDATE ON ldata_table
FOR EACH ROW BEGIN
  IF NEW.datatype = 'logical.file' THEN
    IF NEW.pdriGroupRef != OLD.pdriGroupRef THEN

DROP TABLE IF EXISTS permission_table, ldata_table, wp4_table, pdri_table, pdrigroup_table, storage_site_table, credential_table, requests_table;

CREATE TABLE pdrigroup_table (
  pdriGroupId SERIAL PRIMARY KEY,
