2
0
mirror of https://gitlab.isc.org/isc-projects/kea synced 2025-09-01 22:45:18 +00:00

[#680,!426] Deleted embedded DHCPv6 options when subnet is deleted.

This commit is contained in:
Marcin Siodelski
2019-07-22 13:35:58 +02:00
parent f27f45ec3b
commit e88273f6de
8 changed files with 225 additions and 22 deletions

View File

@@ -2404,6 +2404,51 @@ CREATE TRIGGER dhcp4_subnet_BDEL BEFORE DELETE ON dhcp4_subnet
END $$
DELIMITER ;
# Do not perform cascade deletion of the data in the dhcp6_pool and dhcp6_pd_pool
# because the cascaded deletion does not execute triggers associated with the table.
# Instead we are going to use triggers on the dhcp6_subnet table.
ALTER TABLE dhcp6_pool
DROP FOREIGN KEY fk_dhcp6_pool_subnet_id;
ALTER TABLE dhcp6_pd_pool
DROP FOREIGN KEY fk_dhcp6_pd_pool_subnet_id;
ALTER TABLE dhcp6_pool
ADD CONSTRAINT fk_dhcp6_pool_subnet_id FOREIGN KEY (subnet_id)
REFERENCES dhcp6_subnet (subnet_id)
ON DELETE NO ACTION ON UPDATE CASCADE;
ALTER TABLE dhcp6_pd_pool
ADD CONSTRAINT fk_dhcp6_pd_pool_subnet_id FOREIGN KEY (subnet_id)
REFERENCES dhcp6_subnet (subnet_id)
ON DELETE NO ACTION ON UPDATE CASCADE;
# Create trigger which removes pool specific options upon removal of
# the pool.
DELIMITER $$
CREATE TRIGGER dhcp6_pd_pool_BDEL BEFORE DELETE ON dhcp6_pd_pool FOR EACH ROW
BEGIN
DELETE FROM dhcp6_options WHERE scope_id = 6 AND pd_pool_id = OLD.id;
END
$$
DELIMITER ;
# Drop existing trigger on the dhcp6_subnet table.
DROP TRIGGER dhcp6_subnet_ADEL;
# Create new trigger which will delete pools associated with the subnet and
# the options associated with the subnet.
DELIMITER $$
CREATE TRIGGER dhcp6_subnet_BDEL BEFORE DELETE ON dhcp6_subnet
FOR EACH ROW
BEGIN
CALL createAuditEntryDHCP6('dhcp6_subnet', OLD.subnet_id, "delete");
DELETE FROM dhcp6_pool WHERE subnet_id = OLD.subnet_id;
DELETE FROM dhcp6_pd_pool WHERE subnet_id = OLD.subnet_id;
DELETE FROM dhcp6_options WHERE dhcp6_subnet_id = OLD.subnet_id;
END $$
DELIMITER ;
# Update the schema version number
UPDATE schema_version