use provisioning;

DROP TRIGGER voip_pgrp_drepl_trig;

DELIMITER |

CREATE TRIGGER voip_pgrp_drepl_trig AFTER DELETE ON voip_peer_groups
  FOR EACH ROW BEGIN

  DELETE FROM kamailio.lcr_rule WHERE group_id = OLD.id;
  DELETE FROM kamailio.lcr_gw WHERE group_id = OLD.id;

  END;
|

DELIMITER ;
