mirror of https://github.com/sipwise/db-schema.git
New foreign keys: - 'sub_id_ref' - towards 'subscriber.id' - 'lcr_gw_ref' - towards 'lcr_gw.id' Beforehand delete all alone subscriber_id's from the 'sems_registrations' in case they for some reason exist, this will prevent us from .up script failure. Change-Id: Ib225cc11771c9038c408f6c409d95a417e7ac311mr10.1
parent
31527c2281
commit
9323802ec3
@ -0,0 +1,4 @@
|
||||
use kamailio;
|
||||
ALTER TABLE kamailio.sems_registrations
|
||||
DROP FOREIGN KEY `sub_id_ref`,
|
||||
DROP FOREIGN KEY `lcr_gw_ref`;
|
||||
@ -0,0 +1,9 @@
|
||||
use kamailio;
|
||||
|
||||
SET autocommit=0;
|
||||
DELETE FROM `sems_registrations` WHERE `sems_registrations`.`subscriber_id` NOT IN (SELECT `id` FROM `subscriber`);
|
||||
COMMIT;
|
||||
|
||||
ALTER TABLE `sems_registrations`
|
||||
ADD CONSTRAINT `sub_id_ref` FOREIGN KEY (`subscriber_id`) REFERENCES `subscriber` (`id`) ON DELETE CASCADE ON UPDATE CASCADE,
|
||||
ADD CONSTRAINT `lcr_gw_ref` FOREIGN KEY (`peer_host_id`) REFERENCES `lcr_gw` (`id`) ON DELETE CASCADE ON UPDATE CASCADE;
|
||||
Loading…
Reference in new issue