Commit 8641448c authored by Francis Dupont's avatar Francis Dupont
Browse files

[295-min-max-lease-time-configuration-options] Moved MySQL schema updates to version 8.1

parent 92f54085
......@@ -1717,6 +1717,7 @@ AC_CONFIG_FILES([Makefile
src/share/database/scripts/mysql/upgrade_5.2_to_6.0.sh
src/share/database/scripts/mysql/upgrade_6.0_to_7.0.sh
src/share/database/scripts/mysql/upgrade_7.0_to_8.0.sh
src/share/database/scripts/mysql/upgrade_8.0_to_8.1.sh
src/share/database/scripts/mysql/wipe_data.sh
src/share/database/scripts/pgsql/Makefile
src/share/database/scripts/pgsql/upgrade_1.0_to_2.0.sh
......
......@@ -258,7 +258,7 @@ mysql_upgrade_test() {
assert_str_eq "1.0" ${version} "Expected kea-admin to return %s, returned value was %s"
# Ok, we have a 1.0 database. Let's upgrade it to 8.0
# Ok, we have a 1.0 database. Let's upgrade it to 8.1
${keaadmin} lease-upgrade mysql -u $db_user -p $db_password -n $db_name -d $db_scripts_dir
ERRCODE=$?
......@@ -689,6 +689,8 @@ EOF
qry="SELECT COUNT(*) FROM parameter_data_type";
run_statement "parameter_data_type count" "$qry" 4;
# Schema upgrade from 8.0 to 8.1
# New lifetime bounds.
# table: dhcp4_shared_network
......@@ -707,9 +709,9 @@ EOF
qry="select subnet_prefix, client_class, interface, modification_ts, preferred_lifetime, min_preferred_lifetime, max_preferred_lifetime, rapid_commit, rebind_timer, relay, renew_timer, require_client_classes, reservation_mode, shared_network_name, subnet_id, user_context, valid_lifetime, min_valid_lifetime, max_valid_lifetime, calculate_tee_times, t1_percent, t2_percent from dhcp6_subnet"
run_statement "dhcp6_subnet" "$qry"
# Verify upgraded schema reports version 8.0
# Verify upgraded schema reports version 8.1
version=$(${keaadmin} lease-version mysql -u $db_user -p $db_password -n $db_name -d $db_scripts_dir)
assert_str_eq "8.0" ${version} "Expected kea-admin to return %s, returned value was %s"
assert_str_eq "8.1" ${version} "Expected kea-admin to return %s, returned value was %s"
# Let's wipe the whole database
mysql_wipe
......
......@@ -52,7 +52,7 @@ const int MLM_MYSQL_FETCH_FAILURE = 0;
/// @name Current database schema version values.
//@{
const uint32_t MYSQL_SCHEMA_VERSION_MAJOR = 8;
const uint32_t MYSQL_SCHEMA_VERSION_MINOR = 0;
const uint32_t MYSQL_SCHEMA_VERSION_MINOR = 1;
//@}
......
......@@ -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
......@@ -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}
......@@ -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:
#
......
......@@ -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';
......
#!/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 $?
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment