CREATE OR REPLACE FUNCTION remove_lightboxitem_id() RETURNS trigger AS '
 BEGIN
  UPDATE lightboxitem SET deleted = new.deleted WHERE lightboxid = new.id;
  RETURN NULL;
 END
' LANGUAGE plpgsql;

CREATE TRIGGER delete_lightboxitems_trigger AFTER UPDATE OF deleted ON lightbox FOR EACH ROW EXECUTE PROCEDURE remove_lightboxitem_id();

