From: Thomas Markwalder Date: Thu, 1 Feb 2018 21:27:31 +0000 (-0500) Subject: [5522] Correct subnet id columns types in Postgresql and MySQL schemas X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=fd8c37eaebd6bc34157fc2b37e21b7b649014749;p=thirdparty%2Fkea.git [5522] Correct subnet id columns types in Postgresql and MySQL schemas Added upgrade scripts; updated schema create scripts, version numbers update tests... --- diff --git a/configure.ac b/configure.ac index 68e5d78ca9..428de07589 100644 --- a/configure.ac +++ b/configure.ac @@ -1327,11 +1327,13 @@ AC_CONFIG_FILES([Makefile src/share/database/scripts/mysql/upgrade_4.0_to_4.1.sh src/share/database/scripts/mysql/upgrade_4.1_to_5.0.sh src/share/database/scripts/mysql/upgrade_5.0_to_5.1.sh + src/share/database/scripts/mysql/upgrade_5.1_to_5.2.sh src/share/database/scripts/pgsql/Makefile src/share/database/scripts/pgsql/upgrade_1.0_to_2.0.sh src/share/database/scripts/pgsql/upgrade_2.0_to_3.0.sh src/share/database/scripts/pgsql/upgrade_3.0_to_3.1.sh src/share/database/scripts/pgsql/upgrade_3.1_to_3.2.sh + src/share/database/scripts/pgsql/upgrade_3.2_to_3.3.sh tools/Makefile tools/path_replacer.sh ]) diff --git a/src/bin/admin/tests/mysql_tests.sh.in b/src/bin/admin/tests/mysql_tests.sh.in index 2dc9968a45..aa9996a3d1 100644 --- a/src/bin/admin/tests/mysql_tests.sh.in +++ b/src/bin/admin/tests/mysql_tests.sh.in @@ -351,9 +351,9 @@ EOF count=`echo $text | grep -ic unsigned` assert_eq 1 $count "dhcp6_subnet_id is not of unsigned type. (expected count %d, returned %d)" - # Verify upgraded schema reports version 5.1 + # Verify upgraded schema reports version 5.2 version=$(${keaadmin} lease-version mysql -u $db_user -p $db_password -n $db_name -d $db_scripts_dir) - assert_str_eq "5.1" ${version} "Expected kea-admin to return %s, returned value was %s" + assert_str_eq "5.2" ${version} "Expected kea-admin to return %s, returned value was %s" # Let's wipe the whole database mysql_wipe diff --git a/src/bin/admin/tests/pgsql_tests.sh.in b/src/bin/admin/tests/pgsql_tests.sh.in index 41b7437e02..ca46aefb2b 100644 --- a/src/bin/admin/tests/pgsql_tests.sh.in +++ b/src/bin/admin/tests/pgsql_tests.sh.in @@ -89,7 +89,7 @@ pgsql_lease_version_test() { # Verify that kea-admin lease-version returns the correct version version=$(${keaadmin} lease-version pgsql -u $db_user -p $db_password -n $db_name) - assert_str_eq "3.2" ${version} "Expected kea-admin to return %s, returned value was %s" + assert_str_eq "3.3" ${version} "Expected kea-admin to return %s, returned value was %s" # Let's wipe the whole database pgsql_wipe @@ -199,10 +199,10 @@ pgsql_upgrade_2_0_to_3_0() { assert_eq 1 "$output" "lease_hwaddr_source does not contain entry for HWADDR_SOURCE_UNKNOWN. (record count %d, expected %d)" } -pgsql_upgrade_3_0_to_3_1() { - # Verify upgraded schema reports version 3.1. +pgsql_upgrade_3_0_to_3_3() { + # Verify upgraded schema reports version 3.3. version=$(${keaadmin} lease-version pgsql -u $db_user -p $db_password -n $db_name -d $db_scripts_dir) - assert_str_eq "3.1" ${version} "Expected kea-admin to return %s, returned value was %s" + assert_str_eq "3.3" ${version} "Expected kea-admin to return %s, returned value was %s" } pgsql_upgrade_test() { @@ -224,8 +224,8 @@ pgsql_upgrade_test() { # Check 2.0 to 3.0 upgrade pgsql_upgrade_2_0_to_3_0 - # Check 3.0 to 3.1 upgrade - pgsql_upgrade_3_0_to_3_1 + # Check 3.0 to 3.3 upgrade + pgsql_upgrade_3_0_to_3_3 # Let's wipe the whole database pgsql_wipe diff --git a/src/lib/dhcpsrv/mysql_connection.h b/src/lib/dhcpsrv/mysql_connection.h index 322b33fdae..44f2b8e384 100644 --- a/src/lib/dhcpsrv/mysql_connection.h +++ b/src/lib/dhcpsrv/mysql_connection.h @@ -41,7 +41,7 @@ extern const int MLM_MYSQL_FETCH_FAILURE; /// @name Current database schema version values. //@{ const uint32_t MYSQL_SCHEMA_VERSION_MAJOR = 5; -const uint32_t MYSQL_SCHEMA_VERSION_MINOR = 1; +const uint32_t MYSQL_SCHEMA_VERSION_MINOR = 2; //@} diff --git a/src/lib/dhcpsrv/pgsql_connection.h b/src/lib/dhcpsrv/pgsql_connection.h index 9aab9bfa35..988168ec30 100644 --- a/src/lib/dhcpsrv/pgsql_connection.h +++ b/src/lib/dhcpsrv/pgsql_connection.h @@ -17,9 +17,9 @@ namespace isc { namespace dhcp { -/// @brief Define PostgreSQL backend version: 3.2 +/// @brief Define PostgreSQL backend version: 3.3 const uint32_t PG_SCHEMA_VERSION_MAJOR = 3; -const uint32_t PG_SCHEMA_VERSION_MINOR = 2; +const uint32_t PG_SCHEMA_VERSION_MINOR = 3; // Maximum number of parameters that can be used a statement // @todo This allows us to use an initializer list (since we can't diff --git a/src/share/database/scripts/mysql/.gitignore b/src/share/database/scripts/mysql/.gitignore index f4c4eb0e8b..95f9c34a65 100644 --- a/src/share/database/scripts/mysql/.gitignore +++ b/src/share/database/scripts/mysql/.gitignore @@ -4,3 +4,5 @@ /upgrade_4.0_to_4.1.sh /upgrade_4.1_to_5.0.sh /upgrade_5.0_to_5.1.sh +/upgrade_5.1_to_5.2.sh + diff --git a/src/share/database/scripts/mysql/dhcpdb_create.mysql b/src/share/database/scripts/mysql/dhcpdb_create.mysql index bb82fc33dd..8cb95e5119 100644 --- a/src/share/database/scripts/mysql/dhcpdb_create.mysql +++ b/src/share/database/scripts/mysql/dhcpdb_create.mysql @@ -504,6 +504,16 @@ UPDATE schema_version SET version = '5', minor = '1'; # This line concludes database upgrade to version 5.1. +# Make subnet_id column types consistent with lease table columns +ALTER TABLE dhcp4_options MODIFY dhcp4_subnet_id INT UNSIGNED; +ALTER TABLE dhcp6_options MODIFY dhcp6_subnet_id INT UNSIGNED; + +# Update the schema version number +UPDATE schema_version +SET version = '5', minor = '2'; + +# This line concludes database upgrade to version 5.2. + # Notes: # # Indexes diff --git a/src/share/database/scripts/mysql/upgrade_5.1_to_5.2.sh.in b/src/share/database/scripts/mysql/upgrade_5.1_to_5.2.sh.in new file mode 100644 index 0000000000..b692f69121 --- /dev/null +++ b/src/share/database/scripts/mysql/upgrade_5.1_to_5.2.sh.in @@ -0,0 +1,33 @@ +#!/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" != "5.1" ]; then + printf "This script upgrades 5.1 to 5.2. Reported version is $VERSION. Skipping upgrade.\n" + exit 0 +fi + +mysql "$@" </dev/null <