src/share/database/scripts/mysql/upgrade_3.0_to_4.0.sh
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/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
tools/Makefile
tools/path_replacer.sh
])
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 5.0
+ # Ok, we have a 1.0 database. Let's upgrade it to 5.1
${keaadmin} lease-upgrade mysql -u $db_user -p $db_password -n $db_name -d $db_scripts_dir
ERRCODE=$?
count=`mysql_execute "${qry}"`
ERRCODE=$?
assert_eq 0 $ERRCODE "select from host_identifier_type failed. (expected status code %d, returned %d)"
- assert_eq 3 "$count" "host_identifier_type does not contain correct number of entries. (expected count %d, returned %d)"
+ assert_eq 4 "$count" "host_identifier_type does not contain correct number of entries. (expected count %d, returned %d)"
# verify that foreign key fk_host_identifier_type exists
qry="show create table hosts";
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.0
+ # Verify upgraded schema reports version 5.1
version=$(${keaadmin} lease-version mysql -u $db_user -p $db_password -n $db_name -d $db_scripts_dir)
- assert_str_eq "5.0" ${version} "Expected kea-admin to return %s, returned value was %s"
+ assert_str_eq "5.1" ${version} "Expected kea-admin to return %s, returned value was %s"
# Let's wipe the whole database
mysql_wipe
# 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.0" ${version} "Expected kea-admin to return %s, returned value was %s"
+ assert_str_eq "3.1" ${version} "Expected kea-admin to return %s, returned value was %s"
# Let's wipe the whole database
pgsql_wipe
ERRCODE=$?
assert_eq 0 $ERRCODE "select from lease_hwaddr_source failed. (expected status code %d, returned %d)"
assert_eq 1 "$output" "lease_hwaddr_source does not contain entry for HWADDR_SOURCE_UKNOWN. (record count %d, expected %d)"
+}
- # Verify upgraded schemd reports version 3.0.
+pgsql_upgrade_3_0_to_3_1() {
+ # Verify upgraded schemd reports version 3.1.
version=$(${keaadmin} lease-version pgsql -u $db_user -p $db_password -n $db_name -d $db_scripts_dir)
- assert_str_eq "3.0" ${version} "Expected kea-admin to return %s, returned value was %s"
+ assert_str_eq "3.1" ${version} "Expected kea-admin to return %s, returned value was %s"
}
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
+
# Let's wipe the whole database
pgsql_wipe
-// Copyright (C) 2012-2016 Internet Systems Consortium, Inc. ("ISC")
+// Copyright (C) 2012-2017 Internet Systems Consortium, Inc. ("ISC")
//
// This Source Code Form is subject to the terms of the Mozilla Public
// License, v. 2.0. If a copy of the MPL was not distributed with this
/// @name Current database schema version values.
//@{
const uint32_t MYSQL_SCHEMA_VERSION_MAJOR = 5;
-const uint32_t MYSQL_SCHEMA_VERSION_MINOR = 0;
+const uint32_t MYSQL_SCHEMA_VERSION_MINOR = 1;
//@}
/// @brief Define PostgreSQL backend version: 3.0
const uint32_t PG_SCHEMA_VERSION_MAJOR = 3;
-const uint32_t PG_SCHEMA_VERSION_MINOR = 0;
+const uint32_t PG_SCHEMA_VERSION_MINOR = 1;
// Maximum number of parameters that can be used a statement
// @todo This allows us to use an initializer list (since we can't
/upgrade_3.0_to_4.0.sh
/upgrade_4.0_to_4.1.sh
/upgrade_4.1_to_5.0.sh
+/upgrade_5.0_to_5.1.sh
) ENGINE = INNODB;
START TRANSACTION;
-INSERT INTO host_identifier_type VALUES (0, 'hw-address'); # Non-temporary v6 addresses
-INSERT INTO host_identifier_type VALUES (1, 'duid'); # Temporary v6 addresses
-INSERT INTO host_identifier_type VALUES (2, 'circuit-id'); # Prefix delegations
+INSERT INTO host_identifier_type VALUES (0, 'hw-address');
+INSERT INTO host_identifier_type VALUES (1, 'duid');
+INSERT INTO host_identifier_type VALUES (2, 'circuit-id');
COMMIT;
# Add a constraint that any identifier type value added to the hosts
SET version = '5', minor = '0';
# This line concludes database upgrade to version 5.0.
+# Add indexes for lease tables which will be used to perform searches
+# for all leases by subnet id.
+CREATE INDEX lease4_subnet_id ON lease4 (subnet_id ASC);
+CREATE INDEX lease6_subnet_id ON lease6 (subnet_id ASC);
+
+# Add missing 'client-id' host identifier type.
+INSERT INTO host_identifier_type VALUES (3, 'client-id');
+
+# Update the schema version number
+UPDATE schema_version
+SET version = '5', minor = '1';
+# This line concludes database upgrade to version 5.1.
+
# Notes:
#
# Indexes
--- /dev/null
+#!/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.0" ]; then
+ printf "This script upgrades 5.0 to 5.1. Reported version is $VERSION. Skipping upgrade.\n"
+ exit 0
+fi
+
+mysql "$@" <<EOF
+
+# Add missing 'client-id' host identifier type.
+INSERT INTO host_identifier_type VALUES (3, 'client-id');
+
+# Update the schema version number
+UPDATE schema_version
+SET version = '5', minor = '1';
+# This line concludes database upgrade to version 5.1.
+
+EOF
+
+RESULT=$?
+
+exit $?
upgrade_1.0_to_2.0.sh
upgrade_2.0_to_3.0.sh
+upgrade_3.0_to_3.1.sh
-- Schema 3.0 specification ends here.
+-- This is a placeholder for the changes between 3.0 and 3.1. Even if there
+-- are no further changes the schema version should be set to 3.1, because
+-- we have added a missing 'client-id' host reservation type entry in the
+-- 3.0 -> 3.1 upgrade script. This entry had been accidentally omitted when
+-- the 2.0 -> 3.0 upgrade script was created.
+
+-- Set 3.1 schema version.
+UPDATE schema_version
+ SET version = '3', minor = '1';
+
+
-- Commit the script transaction.
COMMIT;
--- /dev/null
+#!/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=`pgsql_version "$@"`
+
+if [ "$VERSION" != "3.0" ]; then
+ printf "This script upgrades 3.0 to 3.1. Reported version is $VERSION. Skipping upgrade.\n"
+ exit 0
+fi
+
+psql "$@" >/dev/null <<EOF
+
+START TRANSACTION;
+
+-- Upgrade to schema 3.1 begins here:
+
+-- The 'client-id' host identifier type was missing in the
+-- 2.0 -> 3.0 upgrade script. However, it was present in the
+-- dhcpdb_create.pgsql file. This means that this entry may
+-- or may not be present. By the conditional insert below we
+-- will only insert it if it doesn't exist.
+INSERT INTO host_identifier_type (type, name)
+ SELECT 3, 'client-id'
+ WHERE NOT EXISTS (
+ SELECT type FROM host_identifier_type WHERE type = 3
+ );
+
+-- Set 3.1 schema version.
+UPDATE schema_version
+ SET version = '3', minor = '1';
+
+-- Schema 3.1 specification ends here.
+
+-- Commit the script transaction
+COMMIT;
+
+EOF
+
+exit $RESULT
+