[chmod +x src/share/database/scripts/mysql/upgrade_021_to_022.sh])
AC_CONFIG_FILES([src/share/database/scripts/mysql/upgrade_022_to_022.1.sh],
[chmod +x src/share/database/scripts/mysql/upgrade_022_to_022.1.sh])
+AC_CONFIG_FILES([src/share/database/scripts/mysql/upgrade_022.1_to_022.2.sh],
+ [chmod +x src/share/database/scripts/mysql/upgrade_022.1_to_022.2.sh])
AC_CONFIG_FILES([src/share/database/scripts/mysql/wipe_data.sh],
[chmod +x src/share/database/scripts/mysql/wipe_data.sh])
AC_CONFIG_FILES([src/share/database/scripts/pgsql/Makefile])
[chmod +x src/share/database/scripts/pgsql/upgrade_021_to_022.sh])
AC_CONFIG_FILES([src/share/database/scripts/pgsql/upgrade_022_to_022.1.sh],
[chmod +x src/share/database/scripts/pgsql/upgrade_022_to_022.1.sh])
+AC_CONFIG_FILES([src/share/database/scripts/pgsql/upgrade_022.1_to_022.2.sh],
+ [chmod +x src/share/database/scripts/pgsql/upgrade_022.1_to_022.2.sh])
AC_CONFIG_FILES([src/share/database/scripts/pgsql/wipe_data.sh],
[chmod +x src/share/database/scripts/pgsql/wipe_data.sh])
AC_CONFIG_FILES([src/share/yang/Makefile])
printf "Verifying upgrade permissions for %s\n" "$db_user"
mysql_can_create
- upgrade_scripts=$(find "${upgrade_scripts_dir}" -type f -name 'upgrade_*.sh' | sort -V)
+ upgrade_scripts=$(find "${upgrade_scripts_dir}" -type f -name 'upgrade_*.sh' | sort -t'_' -k4 -V)
for script in ${upgrade_scripts}
do
echo "Processing $script file..."
# thru an env
export PGPASSWORD=$db_password
- upgrade_scripts=$(find "${upgrade_scripts_dir}" -type f -name 'upgrade_*.sh' | sort -V)
+ upgrade_scripts=$(find "${upgrade_scripts_dir}" -type f -name 'upgrade_*.sh' | sort -t'_' -k4 -V)
for script in ${upgrade_scripts}
do
echo "Processing $script file..."
assert_str_eq '18' "${OUTPUT}" "${query}: expected output %s, returned %s"
}
+mysql_upgrade_22_1_to_22_2_test() {
+ query="SELECT count(id) FROM option_def_data_type"
+ run_command \
+ mysql_execute "${query}"
+ assert_eq 0 "${EXIT_CODE}" "${query}: expected %d, returned %d"
+ assert_str_eq '18' "${OUTPUT}" "${query}: expected output %s, returned %s"
+
+ qry="select name from option_def_data_type where id = 0"
+ run_command \
+ mysql_execute "${qry}"
+ assert_eq 0 "${EXIT_CODE}" "${qry}. (expected status code %d, returned %d)"
+ assert_str_eq 'empty' "${OUTPUT}" "${query}: expected output %s, returned %s"
+
+ qry="select name from option_def_data_type where id = 1"
+ run_command \
+ mysql_execute "${qry}"
+ assert_eq 0 "${EXIT_CODE}" "${qry}. (expected status code %d, returned %d)"
+ assert_str_eq 'binary' "${OUTPUT}" "${query}: expected output %s, returned %s"
+
+ qry="select name from option_def_data_type where id = 2"
+ run_command \
+ mysql_execute "${qry}"
+ assert_eq 0 "${EXIT_CODE}" "${qry}. (expected status code %d, returned %d)"
+ assert_str_eq 'boolean' "${OUTPUT}" "${query}: expected output %s, returned %s"
+
+ qry="select name from option_def_data_type where id = 3"
+ run_command \
+ mysql_execute "${qry}"
+ assert_eq 0 "${EXIT_CODE}" "${qry}. (expected status code %d, returned %d)"
+ assert_str_eq 'int8' "${OUTPUT}" "${query}: expected output %s, returned %s"
+
+ qry="select name from option_def_data_type where id = 4"
+ run_command \
+ mysql_execute "${qry}"
+ assert_eq 0 "${EXIT_CODE}" "${qry}. (expected status code %d, returned %d)"
+ assert_str_eq 'int16' "${OUTPUT}" "${query}: expected output %s, returned %s"
+
+ qry="select name from option_def_data_type where id = 5"
+ run_command \
+ mysql_execute "${qry}"
+ assert_eq 0 "${EXIT_CODE}" "${qry}. (expected status code %d, returned %d)"
+ assert_str_eq 'int32' "${OUTPUT}" "${query}: expected output %s, returned %s"
+
+ qry="select name from option_def_data_type where id = 6"
+ run_command \
+ mysql_execute "${qry}"
+ assert_eq 0 "${EXIT_CODE}" "${qry}. (expected status code %d, returned %d)"
+ assert_str_eq 'uint8' "${OUTPUT}" "${query}: expected output %s, returned %s"
+
+ qry="select name from option_def_data_type where id = 7"
+ run_command \
+ mysql_execute "${qry}"
+ assert_eq 0 "${EXIT_CODE}" "${qry}. (expected status code %d, returned %d)"
+ assert_str_eq 'uint16' "${OUTPUT}" "${query}: expected output %s, returned %s"
+
+ qry="select name from option_def_data_type where id = 8"
+ run_command \
+ mysql_execute "${qry}"
+ assert_eq 0 "${EXIT_CODE}" "${qry}. (expected status code %d, returned %d)"
+ assert_str_eq 'uint32' "${OUTPUT}" "${query}: expected output %s, returned %s"
+
+ qry="select name from option_def_data_type where id = 10"
+ run_command \
+ mysql_execute "${qry}"
+ assert_eq 0 "${EXIT_CODE}" "${qry}. (expected status code %d, returned %d)"
+ assert_str_eq 'ipv4-address' "${OUTPUT}" "${query}: expected output %s, returned %s"
+
+ qry="select name from option_def_data_type where id = 11"
+ run_command \
+ mysql_execute "${qry}"
+ assert_eq 0 "${EXIT_CODE}" "${qry}. (expected status code %d, returned %d)"
+ assert_str_eq 'ipv6-address' "${OUTPUT}" "${query}: expected output %s, returned %s"
+
+ qry="select name from option_def_data_type where id = 12"
+ run_command \
+ mysql_execute "${qry}"
+ assert_eq 0 "${EXIT_CODE}" "${qry}. (expected status code %d, returned %d)"
+ assert_str_eq 'ipv6-prefix' "${OUTPUT}" "${query}: expected output %s, returned %s"
+
+ qry="select name from option_def_data_type where id = 13"
+ run_command \
+ mysql_execute "${qry}"
+ assert_eq 0 "${EXIT_CODE}" "${qry}. (expected status code %d, returned %d)"
+ assert_str_eq 'psid' "${OUTPUT}" "${query}: expected output %s, returned %s"
+
+ qry="select name from option_def_data_type where id = 14"
+ run_command \
+ mysql_execute "${qry}"
+ assert_eq 0 "${EXIT_CODE}" "${qry}. (expected status code %d, returned %d)"
+ assert_str_eq 'string' "${OUTPUT}" "${query}: expected output %s, returned %s"
+
+ qry="select name from option_def_data_type where id = 15"
+ run_command \
+ mysql_execute "${qry}"
+ assert_eq 0 "${EXIT_CODE}" "${qry}. (expected status code %d, returned %d)"
+ assert_str_eq 'tuple' "${OUTPUT}" "${query}: expected output %s, returned %s"
+
+ qry="select name from option_def_data_type where id = 16"
+ run_command \
+ mysql_execute "${qry}"
+ assert_eq 0 "${EXIT_CODE}" "${qry}. (expected status code %d, returned %d)"
+ assert_str_eq 'fqdn' "${OUTPUT}" "${query}: expected output %s, returned %s"
+
+ qry="select name from option_def_data_type where id = 17"
+ run_command \
+ mysql_execute "${qry}"
+ assert_eq 0 "${EXIT_CODE}" "${qry}. (expected status code %d, returned %d)"
+ assert_str_eq 'internal' "${OUTPUT}" "${query}: expected output %s, returned %s"
+
+ qry="select name from option_def_data_type where id = 254"
+ run_command \
+ mysql_execute "${qry}"
+ assert_eq 0 "${EXIT_CODE}" "${qry}. (expected status code %d, returned %d)"
+ assert_str_eq 'record' "${OUTPUT}" "${query}: expected output %s, returned %s"
+}
+
mysql_upgrade_test() {
test_start "mysql.upgrade"
# Verify that the upgraded schema reports the latest version.
version=$("${kea_admin}" db-version mysql -u "${db_user}" -p "${db_password}" -n "${db_name}" -d "${db_scripts_dir}")
- assert_str_eq "22.1" "${version}" "Expected kea-admin to return %s, returned value was %s"
+ assert_str_eq "22.2" "${version}" "Expected kea-admin to return %s, returned value was %s"
# Let's check that the new tables are indeed there.
# Check upgrade from 22.0 to 22.1.
mysql_upgrade_22_0_to_22_1_test
+
+ # Check upgrade from 22.1 to 22.2.
+ mysql_upgrade_22_1_to_22_2_test
# Let's wipe the whole database
mysql_wipe
run_command \
"${kea_admin}" db-version pgsql -u "${db_user}" -p "${db_password}" -n "${db_name}"
version="${OUTPUT}"
- assert_str_eq "22.1" "${version}" "Expected kea-admin to return %s, returned value was %s"
+ assert_str_eq "22.2" "${version}" "Expected kea-admin to return %s, returned value was %s"
# Let's wipe the whole database
pgsql_wipe
assert_str_eq '4' "${OUTPUT}" "${query}: expected output %s, returned %s"
}
-pgsql_upgrade_22_to_22_1_test() {
+pgsql_upgrade_22_0_to_22_1_test() {
query="SELECT count(id) FROM option_def_data_type"
run_command \
pgsql_execute "${query}"
assert_str_eq '18' "${OUTPUT}" "${query}: expected output %s, returned %s"
}
+pgsql_upgrade_22_1_to_22_2_test() {
+ query="SELECT count(id) FROM option_def_data_type"
+ run_command \
+ pgsql_execute "${query}"
+ assert_eq 0 "${EXIT_CODE}" "${query}: expected %d, returned %d"
+ assert_str_eq '18' "${OUTPUT}" "${query}: expected output %s, returned %s"
+
+ qry="select name from option_def_data_type where id = 0"
+ run_command \
+ pgsql_execute "${qry}"
+ assert_eq 0 "${EXIT_CODE}" "${qry}. (expected status code %d, returned %d)"
+ assert_str_eq 'empty' "${OUTPUT}" "${query}: expected output %s, returned %s"
+
+ qry="select name from option_def_data_type where id = 1"
+ run_command \
+ pgsql_execute "${qry}"
+ assert_eq 0 "${EXIT_CODE}" "${qry}. (expected status code %d, returned %d)"
+ assert_str_eq 'binary' "${OUTPUT}" "${query}: expected output %s, returned %s"
+
+ qry="select name from option_def_data_type where id = 2"
+ run_command \
+ pgsql_execute "${qry}"
+ assert_eq 0 "${EXIT_CODE}" "${qry}. (expected status code %d, returned %d)"
+ assert_str_eq 'boolean' "${OUTPUT}" "${query}: expected output %s, returned %s"
+
+ qry="select name from option_def_data_type where id = 3"
+ run_command \
+ pgsql_execute "${qry}"
+ assert_eq 0 "${EXIT_CODE}" "${qry}. (expected status code %d, returned %d)"
+ assert_str_eq 'int8' "${OUTPUT}" "${query}: expected output %s, returned %s"
+
+ qry="select name from option_def_data_type where id = 4"
+ run_command \
+ pgsql_execute "${qry}"
+ assert_eq 0 "${EXIT_CODE}" "${qry}. (expected status code %d, returned %d)"
+ assert_str_eq 'int16' "${OUTPUT}" "${query}: expected output %s, returned %s"
+
+ qry="select name from option_def_data_type where id = 5"
+ run_command \
+ pgsql_execute "${qry}"
+ assert_eq 0 "${EXIT_CODE}" "${qry}. (expected status code %d, returned %d)"
+ assert_str_eq 'int32' "${OUTPUT}" "${query}: expected output %s, returned %s"
+
+ qry="select name from option_def_data_type where id = 6"
+ run_command \
+ pgsql_execute "${qry}"
+ assert_eq 0 "${EXIT_CODE}" "${qry}. (expected status code %d, returned %d)"
+ assert_str_eq 'uint8' "${OUTPUT}" "${query}: expected output %s, returned %s"
+
+ qry="select name from option_def_data_type where id = 7"
+ run_command \
+ pgsql_execute "${qry}"
+ assert_eq 0 "${EXIT_CODE}" "${qry}. (expected status code %d, returned %d)"
+ assert_str_eq 'uint16' "${OUTPUT}" "${query}: expected output %s, returned %s"
+
+ qry="select name from option_def_data_type where id = 8"
+ run_command \
+ pgsql_execute "${qry}"
+ assert_eq 0 "${EXIT_CODE}" "${qry}. (expected status code %d, returned %d)"
+ assert_str_eq 'uint32' "${OUTPUT}" "${query}: expected output %s, returned %s"
+
+ qry="select name from option_def_data_type where id = 10"
+ run_command \
+ pgsql_execute "${qry}"
+ assert_eq 0 "${EXIT_CODE}" "${qry}. (expected status code %d, returned %d)"
+ assert_str_eq 'ipv4-address' "${OUTPUT}" "${query}: expected output %s, returned %s"
+
+ qry="select name from option_def_data_type where id = 11"
+ run_command \
+ pgsql_execute "${qry}"
+ assert_eq 0 "${EXIT_CODE}" "${qry}. (expected status code %d, returned %d)"
+ assert_str_eq 'ipv6-address' "${OUTPUT}" "${query}: expected output %s, returned %s"
+
+ qry="select name from option_def_data_type where id = 12"
+ run_command \
+ pgsql_execute "${qry}"
+ assert_eq 0 "${EXIT_CODE}" "${qry}. (expected status code %d, returned %d)"
+ assert_str_eq 'ipv6-prefix' "${OUTPUT}" "${query}: expected output %s, returned %s"
+
+ qry="select name from option_def_data_type where id = 13"
+ run_command \
+ pgsql_execute "${qry}"
+ assert_eq 0 "${EXIT_CODE}" "${qry}. (expected status code %d, returned %d)"
+ assert_str_eq 'psid' "${OUTPUT}" "${query}: expected output %s, returned %s"
+
+ qry="select name from option_def_data_type where id = 14"
+ run_command \
+ pgsql_execute "${qry}"
+ assert_eq 0 "${EXIT_CODE}" "${qry}. (expected status code %d, returned %d)"
+ assert_str_eq 'string' "${OUTPUT}" "${query}: expected output %s, returned %s"
+
+ qry="select name from option_def_data_type where id = 15"
+ run_command \
+ pgsql_execute "${qry}"
+ assert_eq 0 "${EXIT_CODE}" "${qry}. (expected status code %d, returned %d)"
+ assert_str_eq 'tuple' "${OUTPUT}" "${query}: expected output %s, returned %s"
+
+ qry="select name from option_def_data_type where id = 16"
+ run_command \
+ pgsql_execute "${qry}"
+ assert_eq 0 "${EXIT_CODE}" "${qry}. (expected status code %d, returned %d)"
+ assert_str_eq 'fqdn' "${OUTPUT}" "${query}: expected output %s, returned %s"
+
+ qry="select name from option_def_data_type where id = 17"
+ run_command \
+ pgsql_execute "${qry}"
+ assert_eq 0 "${EXIT_CODE}" "${qry}. (expected status code %d, returned %d)"
+ assert_str_eq 'internal' "${OUTPUT}" "${query}: expected output %s, returned %s"
+
+ qry="select name from option_def_data_type where id = 254"
+ run_command \
+ pgsql_execute "${qry}"
+ assert_eq 0 "${EXIT_CODE}" "${qry}. (expected status code %d, returned %d)"
+ assert_str_eq 'record' "${OUTPUT}" "${query}: expected output %s, returned %s"
+}
+
pgsql_upgrade_test() {
test_start "pgsql.upgrade"
# Verify upgraded schema reports the latest version.
version=$("${kea_admin}" db-version pgsql -u "${db_user}" -p "${db_password}" -n "${db_name}" -d "${db_scripts_dir}")
- assert_str_eq "22.1" "${version}" 'Expected kea-admin to return %s, returned value was %s'
+ assert_str_eq "22.2" "${version}" 'Expected kea-admin to return %s, returned value was %s'
# Check 1.0 to 2.0 upgrade
pgsql_upgrade_1_0_to_2_0_test
# Check 20 to 21 upgrade
pgsql_upgrade_20_to_21_test
- # Check 22 to 22.1 upgrade
- pgsql_upgrade_22_to_22_1_test
+ # Check 22.0 to 22.1 upgrade
+ pgsql_upgrade_22_0_to_22_1_test
+
+ # Check 22.1 to 22.2 upgrade
+ pgsql_upgrade_22_1_to_22_2_test
# Let's wipe the whole database
pgsql_wipe
/// @name Current database schema version values.
//@{
const uint32_t MYSQL_SCHEMA_VERSION_MAJOR = 22;
-const uint32_t MYSQL_SCHEMA_VERSION_MINOR = 1;
+const uint32_t MYSQL_SCHEMA_VERSION_MINOR = 2;
//@}
/// @brief Define the PostgreSQL backend version.
const uint32_t PGSQL_SCHEMA_VERSION_MAJOR = 22;
-const uint32_t PGSQL_SCHEMA_VERSION_MINOR = 1;
+const uint32_t PGSQL_SCHEMA_VERSION_MINOR = 2;
// Maximum number of parameters that can be used a statement
// @todo This allows us to use an initializer list (since we can't
/upgrade_020_to_021.sh
/upgrade_021_to_022.sh
/upgrade_022_to_022.1.sh
+/upgrade_022.1_to_022.2.sh
/wipe_data.sh
mysql_SCRIPTS += upgrade_020_to_021.sh
mysql_SCRIPTS += upgrade_021_to_022.sh
mysql_SCRIPTS += upgrade_022_to_022.1.sh
+mysql_SCRIPTS += upgrade_022.1_to_022.2.sh
mysql_SCRIPTS += wipe_data.sh
DISTCLEANFILES = ${mysql_SCRIPTS}
(0, 'empty'),
(1, 'binary'),
(2, 'boolean'),
- (3, 'int8"'),
+ (3, 'int8'),
(4, 'int16'),
(5, 'int32'),
(6, 'uint8'),
-- This line concludes the schema upgrade to version 22.1.
+-- This line starts the schema upgrade to version 22.2.
+
+UPDATE option_def_data_type SET name='int8' where id = 3;
+
+-- Update the schema version number.
+UPDATE schema_version
+ SET version = '22', minor = '2';
+
+-- This line concludes the schema upgrade to version 22.2.
+
# Notes:
#
# Indexes
--- /dev/null
+#!/bin/sh
+
+# Copyright (C) 2025 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
+# file, You can obtain one at http://mozilla.org/MPL/2.0/.
+
+# Exit with error if commands exit with non-zero and if undefined variables are
+# used.
+set -eu
+
+# shellcheck disable=SC2034
+# SC2034: ... appears unused. Verify use (or export if used externally).
+prefix="@prefix@"
+
+# Include utilities based on location of this script. Check for sources first,
+# so that the unexpected situations with weird paths fall on the default
+# case of installed.
+script_path=$(cd "$(dirname "${0}")" && pwd)
+if test "${script_path}" = "@abs_top_builddir@/src/share/database/scripts/mysql"; then
+ # shellcheck source=./src/bin/admin/admin-utils.sh.in
+ . "@abs_top_builddir@/src/bin/admin/admin-utils.sh"
+else
+ # shellcheck source=./src/bin/admin/admin-utils.sh.in
+ . "@datarootdir@/@PACKAGE_NAME@/scripts/admin-utils.sh"
+fi
+
+# Check version.
+version=$(mysql_version "${@}")
+if test "${version}" != "22.1"; then
+ printf 'This script upgrades 22.1 to 22.2. '
+ printf 'Reported version is %s. Skipping upgrade.\n' "${version}"
+ exit 0
+fi
+
+# Get the schema name from database argument. We need this to
+# query information_schema for the right database.
+for arg in "${@}"
+do
+ if ! printf '%s' "${arg}" | grep -Eq -- '^--'
+ then
+ schema="$arg"
+ break
+ fi
+done
+
+# Make sure we have the schema.
+if [ -z "$schema" ]
+then
+ printf "Could not find database schema name in cmd line args: %s\n" "${*}"
+ exit 255
+fi
+
+mysql "$@" <<EOF
+
+-- This line starts the schema upgrade to version 22.2.
+
+UPDATE option_def_data_type SET name='int8' WHERE id = 3;
+
+-- Update the schema version number.
+UPDATE schema_version
+ SET version = '22', minor = '2';
+
+-- This line concludes the schema upgrade to version 22.2.
+EOF
/upgrade_020_to_021.sh
/upgrade_021_to_022.sh
/upgrade_022_to_022.1.sh
+/upgrade_022.1_to_022.2.sh
/wipe_data.sh
pgsql_SCRIPTS += upgrade_020_to_021.sh
pgsql_SCRIPTS += upgrade_021_to_022.sh
pgsql_SCRIPTS += upgrade_022_to_022.1.sh
+pgsql_SCRIPTS += upgrade_022.1_to_022.2.sh
pgsql_SCRIPTS += wipe_data.sh
DISTCLEANFILES = ${pgsql_SCRIPTS}
(0, 'empty'),
(1, 'binary'),
(2, 'boolean'),
- (3, 'int8"'),
+ (3, 'int8'),
(4, 'int16'),
(5, 'int32'),
(6, 'uint8'),
ADD CONSTRAINT fk_option_def_data_type6 FOREIGN KEY (type) REFERENCES option_def_data_type(id);
SELECT set_config('kea.disable_audit', 'false', false);
+
+-- Update the schema version number.
UPDATE schema_version
SET version = '22', minor = '1';
-- This line concludes the schema upgrade to version 22.1.
+-- This line starts the schema upgrade to version 22.2.
+
+UPDATE option_def_data_type SET name='int8' where id = 3;
+
+-- Update the schema version number.
+UPDATE schema_version
+ SET version = '22', minor = '2';
+
+-- This line concludes the schema upgrade to version 22.2.
+
-- Commit the script transaction.
COMMIT;
--- /dev/null
+#!/bin/sh
+
+# Copyright (C) 2024 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
+# file, You can obtain one at http://mozilla.org/MPL/2.0/.
+
+# Exit with error if commands exit with non-zero and if undefined variables are
+# used.
+set -eu
+
+# shellcheck disable=SC2034
+# SC2034: ... appears unused. Verify use (or export if used externally).
+prefix="@prefix@"
+
+# Include utilities based on location of this script. Check for sources first,
+# so that the unexpected situations with weird paths fall on the default
+# case of installed.
+script_path=$(cd "$(dirname "${0}")" && pwd)
+if test "${script_path}" = "@abs_top_builddir@/src/share/database/scripts/pgsql"; then
+ # shellcheck source=./src/bin/admin/admin-utils.sh.in
+ . "@abs_top_builddir@/src/bin/admin/admin-utils.sh"
+else
+ # shellcheck source=./src/bin/admin/admin-utils.sh.in
+ . "@datarootdir@/@PACKAGE_NAME@/scripts/admin-utils.sh"
+fi
+
+VERSION=$(pgsql_version "$@")
+
+if [ "$VERSION" != "22.1" ]; then
+ printf 'This script upgrades 22.1 to 22.2. '
+ printf 'Reported version is %s. Skipping upgrade.\n' "${VERSION}"
+ exit 0
+fi
+
+psql "$@" >/dev/null <<EOF
+START TRANSACTION;
+
+-- This line starts the schema upgrade to version 22.2.
+
+UPDATE option_def_data_type SET name='int8' WHERE id = 3;
+
+UPDATE schema_version
+ SET version = '22', minor = '2';
+
+-- This line concludes the schema upgrade to version 22.2.
+
+-- Commit the script transaction.
+COMMIT;
+
+EOF