mirror of
https://gitlab.isc.org/isc-projects/kea
synced 2025-08-23 10:27:36 +00:00
60 lines
1.6 KiB
Bash
60 lines
1.6 KiB
Bash
|
#!/bin/sh
|
||
|
|
||
|
prefix=@prefix@
|
||
|
# Include utilities. Use installed version if available and
|
||
|
# use build version if it isn't.
|
||
|
if [ -e @datarootdir@/@PACKAGE_NAME@/scripts/admin-utils.sh ]; then
|
||
|
. @datarootdir@/@PACKAGE_NAME@/scripts/admin-utils.sh
|
||
|
else
|
||
|
. @abs_top_builddir@/src/bin/admin/admin-utils.sh
|
||
|
fi
|
||
|
|
||
|
VERSION=`mysql_version "$@"`
|
||
|
|
||
|
if [ "$VERSION" != "8.1" ]; then
|
||
|
printf "This script upgrades 8.1 to 8.2. Reported version is $VERSION. Skipping upgrade.\n"
|
||
|
exit 0
|
||
|
fi
|
||
|
|
||
|
mysql "$@" <<EOF
|
||
|
|
||
|
# Do not perform cascade deletion of the data in the dhcp4_pool because
|
||
|
# the cascade deletion does not execute triggers associated with the table.
|
||
|
# Instead we are going to use triggers on the dhcp4_subnet table.
|
||
|
ALTER TABLE dhcp4_pool
|
||
|
DROP FOREIGN KEY fk_dhcp4_pool_subnet_id;
|
||
|
|
||
|
ALTER TABLE dhcp4_pool
|
||
|
ADD CONSTRAINT fk_dhcp4_pool_subnet_id FOREIGN KEY (subnet_id)
|
||
|
REFERENCES dhcp4_subnet (subnet_id)
|
||
|
ON DELETE NO ACTION ON UPDATE CASCADE;
|
||
|
|
||
|
|
||
|
# Drop existing trigger on the dhcp4_subnet table.
|
||
|
DROP TRIGGER dhcp4_subnet_ADEL;
|
||
|
|
||
|
# Create new trigger which will delete pools associated with the subnet and
|
||
|
# the options associated with the subnet.
|
||
|
DELIMITER $$
|
||
|
CREATE TRIGGER dhcp4_subnet_BDEL BEFORE DELETE ON dhcp4_subnet
|
||
|
FOR EACH ROW
|
||
|
BEGIN
|
||
|
CALL createAuditEntryDHCP4('dhcp4_subnet', OLD.subnet_id, "delete");
|
||
|
DELETE FROM dhcp4_pool WHERE subnet_id = OLD.subnet_id;
|
||
|
DELETE FROM dhcp4_options WHERE dhcp4_subnet_id = OLD.subnet_id;
|
||
|
END $$
|
||
|
DELIMITER ;
|
||
|
|
||
|
|
||
|
# Update the schema version number
|
||
|
UPDATE schema_version
|
||
|
SET version = '8', minor = '2';
|
||
|
|
||
|
# This line concludes database upgrade to version 8.2.
|
||
|
|
||
|
EOF
|
||
|
|
||
|
RESULT=$?
|
||
|
|
||
|
exit $?
|