diff options
author | Francis Dupont <fdupont@isc.org> | 2019-06-21 15:17:04 +0200 |
---|---|---|
committer | Francis Dupont <fdupont@isc.org> | 2019-06-22 16:05:24 +0200 |
commit | 8641448c4106bf28ea32df72e5e0ad520d3946ae (patch) | |
tree | 6c21fc10b55bbf0c1845dbfb71a32308b494567d /src/share | |
parent | [295-min-max-lease-time-configuration-options] Improved lifetime bound checks (diff) | |
download | kea-8641448c4106bf28ea32df72e5e0ad520d3946ae.tar.xz kea-8641448c4106bf28ea32df72e5e0ad520d3946ae.zip |
[295-min-max-lease-time-configuration-options] Moved MySQL schema updates to version 8.1
Diffstat (limited to 'src/share')
5 files changed, 62 insertions, 24 deletions
diff --git a/src/share/database/scripts/mysql/.gitignore b/src/share/database/scripts/mysql/.gitignore index 8aa1c26ae0..524e3c8365 100644 --- a/src/share/database/scripts/mysql/.gitignore +++ b/src/share/database/scripts/mysql/.gitignore @@ -8,4 +8,5 @@ /upgrade_5.2_to_6.0.sh /upgrade_6.0_to_7.0.sh /upgrade_7.0_to_8.0.sh +/upgrade_8.0_to_8.1.sh /wipe_data.sh diff --git a/src/share/database/scripts/mysql/Makefile.am b/src/share/database/scripts/mysql/Makefile.am index 61263c38d2..1f85842069 100644 --- a/src/share/database/scripts/mysql/Makefile.am +++ b/src/share/database/scripts/mysql/Makefile.am @@ -13,6 +13,7 @@ sqlscripts_DATA += upgrade_5.1_to_5.2.sh sqlscripts_DATA += upgrade_5.2_to_6.0.sh sqlscripts_DATA += upgrade_6.0_to_7.0.sh sqlscripts_DATA += upgrade_7.0_to_8.0.sh +sqlscripts_DATA += upgrade_8.0_to_8.1.sh sqlscripts_DATA += wipe_data.sh DISTCLEANFILES = upgrade_1.0_to_2.0.sh @@ -25,6 +26,7 @@ DISTCLEANFILES += upgrade_5.1_to_5.2.sh DISTCLEANFILES += upgrade_5.2_to_6.0.sh DISTCLEANFILES += upgrade_6.0_to_7.0.sh DISTCLEANFILES += upgrade_7.0_to_8.0.sh +DISTCLEANFILES += upgrade_8.0_to_8.1.sh DISTCLEANFILES += wipe_data.sh EXTRA_DIST = ${sqlscripts_DATA} diff --git a/src/share/database/scripts/mysql/dhcpdb_create.mysql b/src/share/database/scripts/mysql/dhcpdb_create.mysql index 7efb7f9213..a4c0848da8 100644 --- a/src/share/database/scripts/mysql/dhcpdb_create.mysql +++ b/src/share/database/scripts/mysql/dhcpdb_create.mysql @@ -2286,6 +2286,12 @@ CREATE TRIGGER dhcp6_options_ADEL AFTER DELETE ON dhcp6_options END $$ DELIMITER ; +# Update the schema version number +UPDATE schema_version +SET version = '8', minor = '0'; + +# This line concludes database upgrade to version 8.0. + # Add lifetime bounds ALTER TABLE dhcp4_shared_network ADD COLUMN min_valid_lifetime INT(10) DEFAULT NULL, @@ -2309,10 +2315,9 @@ ALTER TABLE dhcp6_subnet # Update the schema version number UPDATE schema_version -SET version = '8', minor = '0'; - -# This line concludes database upgrade to version 8.0. +SET version = '8', minor = '1'; +# This line concludes database upgrade to version 8.1. # Notes: # diff --git a/src/share/database/scripts/mysql/upgrade_7.0_to_8.0.sh.in b/src/share/database/scripts/mysql/upgrade_7.0_to_8.0.sh.in index 5049a85f5b..8f2a4ebec7 100644 --- a/src/share/database/scripts/mysql/upgrade_7.0_to_8.0.sh.in +++ b/src/share/database/scripts/mysql/upgrade_7.0_to_8.0.sh.in @@ -969,27 +969,6 @@ CREATE TRIGGER dhcp6_options_ADEL AFTER DELETE ON dhcp6_options END $$ DELIMITER ; -# Add lifetime bounds -ALTER TABLE dhcp4_shared_network - ADD COLUMN min_valid_lifetime INT(10) DEFAULT NULL, - ADD COLUMN max_valid_lifetime INT(10) DEFAULT NULL; - -ALTER TABLE dhcp4_subnet - ADD COLUMN min_valid_lifetime INT(10) DEFAULT NULL, - ADD COLUMN max_valid_lifetime INT(10) DEFAULT NULL; - -ALTER TABLE dhcp6_shared_network - ADD COLUMN min_preferred_lifetime INT(10) DEFAULT NULL, - ADD COLUMN max_preferred_lifetime INT(10) DEFAULT NULL, - ADD COLUMN min_valid_lifetime INT(10) DEFAULT NULL, - ADD COLUMN max_valid_lifetime INT(10) DEFAULT NULL; - -ALTER TABLE dhcp6_subnet - ADD COLUMN min_preferred_lifetime INT(10) DEFAULT NULL, - ADD COLUMN max_preferred_lifetime INT(10) DEFAULT NULL, - ADD COLUMN min_valid_lifetime INT(10) DEFAULT NULL, - ADD COLUMN max_valid_lifetime INT(10) DEFAULT NULL; - # Update the schema version number UPDATE schema_version SET version = '8', minor = '0'; diff --git a/src/share/database/scripts/mysql/upgrade_8.0_to_8.1.sh.in b/src/share/database/scripts/mysql/upgrade_8.0_to_8.1.sh.in new file mode 100644 index 0000000000..ba696c944e --- /dev/null +++ b/src/share/database/scripts/mysql/upgrade_8.0_to_8.1.sh.in @@ -0,0 +1,51 @@ +#!/bin/sh + +# 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.0" ]; then + printf "This script upgrades 8.0 to 8.1. Reported version is $VERSION. Skipping upgrade.\n" + exit 0 +fi + +mysql "$@" <<EOF + +# Add lifetime bounds +ALTER TABLE dhcp4_shared_network + ADD COLUMN min_valid_lifetime INT(10) DEFAULT NULL, + ADD COLUMN max_valid_lifetime INT(10) DEFAULT NULL; + +ALTER TABLE dhcp4_subnet + ADD COLUMN min_valid_lifetime INT(10) DEFAULT NULL, + ADD COLUMN max_valid_lifetime INT(10) DEFAULT NULL; + +ALTER TABLE dhcp6_shared_network + ADD COLUMN min_preferred_lifetime INT(10) DEFAULT NULL, + ADD COLUMN max_preferred_lifetime INT(10) DEFAULT NULL, + ADD COLUMN min_valid_lifetime INT(10) DEFAULT NULL, + ADD COLUMN max_valid_lifetime INT(10) DEFAULT NULL; + +ALTER TABLE dhcp6_subnet + ADD COLUMN min_preferred_lifetime INT(10) DEFAULT NULL, + ADD COLUMN max_preferred_lifetime INT(10) DEFAULT NULL, + ADD COLUMN min_valid_lifetime INT(10) DEFAULT NULL, + ADD COLUMN max_valid_lifetime INT(10) DEFAULT NULL; + +# Update the schema version number +UPDATE schema_version +SET version = '8', minor = '1'; + +# This line concludes database upgrade to version 8.1. + +EOF + +RESULT=$? + +exit $? |