diff options
-rw-r--r-- | configure.ac | 4 | ||||
-rw-r--r-- | src/bin/admin/tests/mysql_tests.sh.in | 39 | ||||
-rw-r--r-- | src/bin/admin/tests/pgsql_tests.sh.in | 18 | ||||
-rw-r--r-- | src/lib/mysql/mysql_constants.h | 2 | ||||
-rw-r--r-- | src/lib/pgsql/pgsql_connection.h | 2 | ||||
-rw-r--r-- | src/share/database/scripts/mysql/.gitignore | 1 | ||||
-rw-r--r-- | src/share/database/scripts/mysql/Makefile.am | 1 | ||||
-rw-r--r-- | src/share/database/scripts/mysql/dhcpdb_create.mysql | 29 | ||||
-rw-r--r-- | src/share/database/scripts/mysql/upgrade_026_to_027.sh.in | 85 | ||||
-rw-r--r-- | src/share/database/scripts/pgsql/.gitignore | 1 | ||||
-rw-r--r-- | src/share/database/scripts/pgsql/Makefile.am | 1 | ||||
-rw-r--r-- | src/share/database/scripts/pgsql/dhcpdb_create.pgsql | 27 | ||||
-rw-r--r-- | src/share/database/scripts/pgsql/upgrade_026_to_027.sh.in | 70 |
13 files changed, 264 insertions, 16 deletions
diff --git a/configure.ac b/configure.ac index 791b675ffc..27ee28f316 100644 --- a/configure.ac +++ b/configure.ac @@ -1824,6 +1824,8 @@ AC_CONFIG_FILES([src/share/database/scripts/mysql/upgrade_024_to_025.sh], [chmod +x src/share/database/scripts/mysql/upgrade_024_to_025.sh]) AC_CONFIG_FILES([src/share/database/scripts/mysql/upgrade_025_to_026.sh], [chmod +x src/share/database/scripts/mysql/upgrade_025_to_026.sh]) +AC_CONFIG_FILES([src/share/database/scripts/mysql/upgrade_026_to_027.sh], + [chmod +x src/share/database/scripts/mysql/upgrade_026_to_027.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]) @@ -1889,6 +1891,8 @@ AC_CONFIG_FILES([src/share/database/scripts/pgsql/upgrade_024_to_025.sh], [chmod +x src/share/database/scripts/pgsql/upgrade_024_to_025.sh]) AC_CONFIG_FILES([src/share/database/scripts/pgsql/upgrade_025_to_026.sh], [chmod +x src/share/database/scripts/pgsql/upgrade_025_to_026.sh]) +AC_CONFIG_FILES([src/share/database/scripts/pgsql/upgrade_026_to_027.sh], + [chmod +x src/share/database/scripts/pgsql/upgrade_026_to_027.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]) diff --git a/src/bin/admin/tests/mysql_tests.sh.in b/src/bin/admin/tests/mysql_tests.sh.in index bd936f8aa9..7150c8b2fd 100644 --- a/src/bin/admin/tests/mysql_tests.sh.in +++ b/src/bin/admin/tests/mysql_tests.sh.in @@ -980,6 +980,18 @@ mysql_upgrade_25_to_26_test() { check_table_column only_in_additional_list dhcp6_client_class } +mysql_upgrade_26_to_27_test() { + + # check client_class has become client_classes. + check_table_column client_classes dhcp4_shared_network + check_table_column client_classes dhcp4_subnet + check_table_column client_classes dhcp4_pool + check_table_column client_classes dhcp6_shared_network + check_table_column client_classes dhcp6_subnet + check_table_column client_classes dhcp6_pool + check_table_column client_classes dhcp6_pd_pool +} + mysql_upgrade_test() { test_start "mysql.upgrade" @@ -1001,7 +1013,7 @@ mysql_upgrade_test() { # 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 "26.0" "${version}" "Expected kea-admin to return %s, returned value was %s" + assert_str_eq "27.0" "${version}" "Expected kea-admin to return %s, returned value was %s" # Let's check that the new tables are indeed there. @@ -1247,7 +1259,7 @@ mysql_upgrade_test() { run_statement "dhcp4_option_def_server" "$qry" # table: dhcp4_shared_network - qry="select id, name, client_class, interface, match_client_id, modification_ts, rebind_timer, relay, renew_timer, evaluate_additional_classes, user_context, valid_lifetime, authoritative, calculate_tee_times, t1_percent, t2_percent, boot_file_name, next_server, server_hostname from dhcp4_shared_network" + qry="select id, name, client_classes, interface, match_client_id, modification_ts, rebind_timer, relay, renew_timer, evaluate_additional_classes, user_context, valid_lifetime, authoritative, calculate_tee_times, t1_percent, t2_percent, boot_file_name, next_server, server_hostname from dhcp4_shared_network" run_statement "dhcp4_shared_network" "$qry" # table: dhcp4_shared_network_server @@ -1255,7 +1267,7 @@ mysql_upgrade_test() { run_statement "dhcp4_shared_network_server" "$qry" # table: dhcp4_subnet - qry="select subnet_prefix, 4o6_interface, 4o6_interface_id, 4o6_subnet, boot_file_name, client_class, interface, match_client_id, modification_ts, next_server, rebind_timer, relay, renew_timer, evaluate_additional_classes, server_hostname, shared_network_name, subnet_id, user_context, valid_lifetime, authoritative, calculate_tee_times, t1_percent, t2_percent from dhcp4_subnet" + qry="select subnet_prefix, 4o6_interface, 4o6_interface_id, 4o6_subnet, boot_file_name, client_classes, interface, match_client_id, modification_ts, next_server, rebind_timer, relay, renew_timer, evaluate_additional_classes, server_hostname, shared_network_name, subnet_id, user_context, valid_lifetime, authoritative, calculate_tee_times, t1_percent, t2_percent from dhcp4_subnet" run_statement "dhcp4_subnet" "$qry" # table: dhcp4_pool @@ -1303,7 +1315,7 @@ mysql_upgrade_test() { run_statement "dhcp6_option_def_server" "$qry" # table: dhcp6_shared_network - qry="select id, name, client_class, interface, modification_ts, preferred_lifetime, rapid_commit, rebind_timer, relay, renew_timer, evaluate_additional_classes, user_context, valid_lifetime, calculate_tee_times, t1_percent, t2_percent, interface_id from dhcp6_shared_network" + qry="select id, name, client_classes, interface, modification_ts, preferred_lifetime, rapid_commit, rebind_timer, relay, renew_timer, evaluate_additional_classes, user_context, valid_lifetime, calculate_tee_times, t1_percent, t2_percent, interface_id from dhcp6_shared_network" run_statement "dhcp6_shared_network" "$qry" # table: dhcp6_shared_network_server @@ -1311,7 +1323,7 @@ mysql_upgrade_test() { run_statement "dhcp6_shared_network" "$qry" # table: dhcp6_subnet - qry="select subnet_prefix, client_class, interface, modification_ts, preferred_lifetime, rapid_commit, rebind_timer, relay, renew_timer, evaluate_additional_classes, shared_network_name, subnet_id, user_context, valid_lifetime, calculate_tee_times, t1_percent, t2_percent, interface_id from dhcp6_subnet" + qry="select subnet_prefix, client_classes, interface, modification_ts, preferred_lifetime, rapid_commit, rebind_timer, relay, renew_timer, evaluate_additional_classes, shared_network_name, subnet_id, user_context, valid_lifetime, calculate_tee_times, t1_percent, t2_percent, interface_id from dhcp6_subnet" run_statement "dhcp6_subnet" "$qry" # table: dhcp6_subnet_server @@ -1434,31 +1446,31 @@ mysql_upgrade_test() { # New lifetime bounds. # table: dhcp4_shared_network - qry="select id, name, client_class, interface, match_client_id, modification_ts, rebind_timer, relay, renew_timer, evaluate_additional_classes, user_context, valid_lifetime, min_valid_lifetime, max_valid_lifetime, authoritative, calculate_tee_times, t1_percent, t2_percent, boot_file_name, next_server, server_hostname from dhcp4_shared_network" + qry="select id, name, client_classes, interface, match_client_id, modification_ts, rebind_timer, relay, renew_timer, evaluate_additional_classes, user_context, valid_lifetime, min_valid_lifetime, max_valid_lifetime, authoritative, calculate_tee_times, t1_percent, t2_percent, boot_file_name, next_server, server_hostname from dhcp4_shared_network" run_statement "dhcp4_shared_network" "$qry" # table: dhcp4_subnet - qry="select subnet_prefix, 4o6_interface, 4o6_interface_id, 4o6_subnet, boot_file_name, client_class, interface, match_client_id, modification_ts, next_server, rebind_timer, relay, renew_timer, evaluate_additional_classes, server_hostname, shared_network_name, subnet_id, user_context, valid_lifetime, min_valid_lifetime, max_valid_lifetime, authoritative, calculate_tee_times, t1_percent, t2_percent from dhcp4_subnet" + qry="select subnet_prefix, 4o6_interface, 4o6_interface_id, 4o6_subnet, boot_file_name, client_classes, interface, match_client_id, modification_ts, next_server, rebind_timer, relay, renew_timer, evaluate_additional_classes, server_hostname, shared_network_name, subnet_id, user_context, valid_lifetime, min_valid_lifetime, max_valid_lifetime, authoritative, calculate_tee_times, t1_percent, t2_percent from dhcp4_subnet" run_statement "dhcp4_subnet" "$qry" # table: dhcp6_shared_network - qry="select id, name, client_class, interface, modification_ts, preferred_lifetime, min_preferred_lifetime, max_preferred_lifetime,rapid_commit, rebind_timer, relay, renew_timer, evaluate_additional_classes, user_context, valid_lifetime, min_valid_lifetime, max_valid_lifetime, calculate_tee_times, t1_percent, t2_percent from dhcp6_shared_network" + qry="select id, name, client_classes, interface, modification_ts, preferred_lifetime, min_preferred_lifetime, max_preferred_lifetime,rapid_commit, rebind_timer, relay, renew_timer, evaluate_additional_classes, user_context, valid_lifetime, min_valid_lifetime, max_valid_lifetime, calculate_tee_times, t1_percent, t2_percent from dhcp6_shared_network" run_statement "dhcp6_shared_network" "$qry" # table: dhcp6_subnet - qry="select subnet_prefix, client_class, interface, modification_ts, preferred_lifetime, min_preferred_lifetime, max_preferred_lifetime, rapid_commit, rebind_timer, relay, renew_timer, evaluate_additional_classes, 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" + qry="select subnet_prefix, client_classes, interface, modification_ts, preferred_lifetime, min_preferred_lifetime, max_preferred_lifetime, rapid_commit, rebind_timer, relay, renew_timer, evaluate_additional_classes, 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" # table: dhcp4_pool (should include three new columns) - qry="select client_class, evaluate_additional_classes, user_context from dhcp4_pool" + qry="select client_classes, evaluate_additional_classes, user_context from dhcp4_pool" run_statement "dhcp4_pool" "$qry" # table: dhcp6_pd_pool (should include five new columns) - qry="select excluded_prefix, excluded_prefix_length, client_class, evaluate_additional_classes, user_context from dhcp6_pd_pool" + qry="select excluded_prefix, excluded_prefix_length, client_classes, evaluate_additional_classes, user_context from dhcp6_pd_pool" run_statement "dhcp6_pd_pool" "$qry" # table: dhcp6_pool (should include three new columns) - qry="select client_class, evaluate_additional_classes, user_context from dhcp6_pool" + qry="select client_classes, evaluate_additional_classes, user_context from dhcp6_pool" run_statement "dhcp6_pool" "$qry" # Verify that dhcp4_option_def column name is is_array @@ -1676,6 +1688,9 @@ SET @disable_audit = 0" # Check upgrade from 25.0 to 26.0. mysql_upgrade_25_to_26_test + # Check upgrade from 26.0 to 27.0. + mysql_upgrade_26_to_27_test + # 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 7fa4443d38..fd5c200e18 100644 --- a/src/bin/admin/tests/pgsql_tests.sh.in +++ b/src/bin/admin/tests/pgsql_tests.sh.in @@ -155,7 +155,7 @@ pgsql_db_version_test() { run_command \ "${kea_admin}" db-version pgsql -u "${db_user}" -p "${db_password}" -n "${db_name}" version="${OUTPUT}" - assert_str_eq "26.0" "${version}" "Expected kea-admin to return %s, returned value was %s" + assert_str_eq "27.0" "${version}" "Expected kea-admin to return %s, returned value was %s" # Let's wipe the whole database pgsql_wipe @@ -1072,6 +1072,17 @@ pgsql_upgrade_25_to_26_test() { check_table_column only_in_additional_list dhcp6_client_class } +pgsql_upgrade_26_to_27_test() { + # check client_class has become client_classes. + check_table_column client_classes dhcp4_shared_network + check_table_column client_classes dhcp4_subnet + check_table_column client_classes dhcp4_pool + check_table_column client_classes dhcp6_shared_network + check_table_column client_classes dhcp6_subnet + check_table_column client_classes dhcp6_pool + check_table_column client_classes dhcp6_pd_pool +} + pgsql_upgrade_test() { test_start "pgsql.upgrade" @@ -1090,7 +1101,7 @@ pgsql_upgrade_test() { # 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 "26.0" "${version}" 'Expected kea-admin to return %s, returned value was %s' + assert_str_eq "27.0" "${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 @@ -1161,6 +1172,9 @@ pgsql_upgrade_test() { # Check 25 to 26 upgrade pgsql_upgrade_25_to_26_test + # Check 26 to 27 upgrade + pgsql_upgrade_26_to_27_test + # Let's wipe the whole database pgsql_wipe diff --git a/src/lib/mysql/mysql_constants.h b/src/lib/mysql/mysql_constants.h index 8cdcbea4ef..7d2d640730 100644 --- a/src/lib/mysql/mysql_constants.h +++ b/src/lib/mysql/mysql_constants.h @@ -52,7 +52,7 @@ const int MLM_MYSQL_FETCH_FAILURE = 0; /// @name Current database schema version values. //@{ -const uint32_t MYSQL_SCHEMA_VERSION_MAJOR = 26; +const uint32_t MYSQL_SCHEMA_VERSION_MAJOR = 27; const uint32_t MYSQL_SCHEMA_VERSION_MINOR = 0; //@} diff --git a/src/lib/pgsql/pgsql_connection.h b/src/lib/pgsql/pgsql_connection.h index 5667dd7927..73cad71426 100644 --- a/src/lib/pgsql/pgsql_connection.h +++ b/src/lib/pgsql/pgsql_connection.h @@ -18,7 +18,7 @@ namespace isc { namespace db { /// @brief Define the PostgreSQL backend version. -const uint32_t PGSQL_SCHEMA_VERSION_MAJOR = 26; +const uint32_t PGSQL_SCHEMA_VERSION_MAJOR = 27; const uint32_t PGSQL_SCHEMA_VERSION_MINOR = 0; // Maximum number of parameters that can be used a statement diff --git a/src/share/database/scripts/mysql/.gitignore b/src/share/database/scripts/mysql/.gitignore index 0b4c5489c9..e67addfeb8 100644 --- a/src/share/database/scripts/mysql/.gitignore +++ b/src/share/database/scripts/mysql/.gitignore @@ -34,4 +34,5 @@ /upgrade_023_to_024.sh /upgrade_024_to_025.sh /upgrade_025_to_026.sh +/upgrade_026_to_027.sh /wipe_data.sh diff --git a/src/share/database/scripts/mysql/Makefile.am b/src/share/database/scripts/mysql/Makefile.am index 7bcaba6502..bedb59088b 100644 --- a/src/share/database/scripts/mysql/Makefile.am +++ b/src/share/database/scripts/mysql/Makefile.am @@ -45,6 +45,7 @@ mysql_SCRIPTS += upgrade_022_to_023.sh mysql_SCRIPTS += upgrade_023_to_024.sh mysql_SCRIPTS += upgrade_024_to_025.sh mysql_SCRIPTS += upgrade_025_to_026.sh +mysql_SCRIPTS += upgrade_026_to_027.sh mysql_SCRIPTS += wipe_data.sh DISTCLEANFILES = ${mysql_SCRIPTS} diff --git a/src/share/database/scripts/mysql/dhcpdb_create.mysql b/src/share/database/scripts/mysql/dhcpdb_create.mysql index 723d26e966..a212dc8cf9 100644 --- a/src/share/database/scripts/mysql/dhcpdb_create.mysql +++ b/src/share/database/scripts/mysql/dhcpdb_create.mysql @@ -6068,6 +6068,35 @@ UPDATE schema_version -- This line concludes the schema upgrade to version 26.0. +-- This line starts the schema upgrade to version 27.0. + +ALTER TABLE dhcp4_shared_network + CHANGE client_class client_classes LONGTEXT DEFAULT NULL; + +ALTER TABLE dhcp4_subnet + CHANGE client_class client_classes LONGTEXT DEFAULT NULL; + +ALTER TABLE dhcp4_pool + CHANGE client_class client_classes LONGTEXT DEFAULT NULL; + +ALTER TABLE dhcp6_shared_network + CHANGE client_class client_classes LONGTEXT DEFAULT NULL; + +ALTER TABLE dhcp6_subnet + CHANGE client_class client_classes LONGTEXT DEFAULT NULL; + +ALTER TABLE dhcp6_pool + CHANGE client_class client_classes LONGTEXT DEFAULT NULL; + +ALTER TABLE dhcp6_pd_pool + CHANGE client_class client_classes LONGTEXT DEFAULT NULL; + +-- Update the schema version number. +UPDATE schema_version + SET version = '27', minor = '0'; + +-- This line concludes the schema upgrade to version 27.0. + # Notes: # # Indexes diff --git a/src/share/database/scripts/mysql/upgrade_026_to_027.sh.in b/src/share/database/scripts/mysql/upgrade_026_to_027.sh.in new file mode 100644 index 0000000000..552eb179ae --- /dev/null +++ b/src/share/database/scripts/mysql/upgrade_026_to_027.sh.in @@ -0,0 +1,85 @@ +#!/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/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}" != "26.0"; then + printf 'This script upgrades 27.0 to 27.0. ' + 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 27.0. + +ALTER TABLE dhcp4_shared_network + CHANGE client_class client_classes LONGTEXT DEFAULT NULL; + +ALTER TABLE dhcp4_subnet + CHANGE client_class client_classes LONGTEXT DEFAULT NULL; + +ALTER TABLE dhcp4_pool + CHANGE client_class client_classes LONGTEXT DEFAULT NULL; + +ALTER TABLE dhcp6_shared_network + CHANGE client_class client_classes LONGTEXT DEFAULT NULL; + +ALTER TABLE dhcp6_subnet + CHANGE client_class client_classes LONGTEXT DEFAULT NULL; + +ALTER TABLE dhcp6_pool + CHANGE client_class client_classes LONGTEXT DEFAULT NULL; + +ALTER TABLE dhcp6_pd_pool + CHANGE client_class client_classes LONGTEXT DEFAULT NULL; + +-- Update the schema version number. +UPDATE schema_version + SET version = '27', minor = '0'; + +-- This line concludes the schema upgrade to version 27.0. +EOF diff --git a/src/share/database/scripts/pgsql/.gitignore b/src/share/database/scripts/pgsql/.gitignore index ae7b60b035..f77ce459a0 100644 --- a/src/share/database/scripts/pgsql/.gitignore +++ b/src/share/database/scripts/pgsql/.gitignore @@ -29,4 +29,5 @@ /upgrade_023_to_024.sh /upgrade_024_to_025.sh /upgrade_025_to_026.sh +/upgrade_026_to_027.sh /wipe_data.sh diff --git a/src/share/database/scripts/pgsql/Makefile.am b/src/share/database/scripts/pgsql/Makefile.am index fd0ef79f35..25614f3b3a 100644 --- a/src/share/database/scripts/pgsql/Makefile.am +++ b/src/share/database/scripts/pgsql/Makefile.am @@ -40,6 +40,7 @@ pgsql_SCRIPTS += upgrade_022_to_023.sh pgsql_SCRIPTS += upgrade_023_to_024.sh pgsql_SCRIPTS += upgrade_024_to_025.sh pgsql_SCRIPTS += upgrade_025_to_026.sh +pgsql_SCRIPTS += upgrade_026_to_027.sh pgsql_SCRIPTS += wipe_data.sh DISTCLEANFILES = ${pgsql_SCRIPTS} diff --git a/src/share/database/scripts/pgsql/dhcpdb_create.pgsql b/src/share/database/scripts/pgsql/dhcpdb_create.pgsql index a25a800024..87c2448a5b 100644 --- a/src/share/database/scripts/pgsql/dhcpdb_create.pgsql +++ b/src/share/database/scripts/pgsql/dhcpdb_create.pgsql @@ -6529,6 +6529,33 @@ UPDATE schema_version -- This line concludes the schema upgrade to version 26.0. +-- This line starts the schema upgrade to version 27.0. + +ALTER TABLE dhcp4_shared_network RENAME client_class TO client_classes; +ALTER TABLE dhcp4_shared_network ALTER COLUMN client_classes TYPE TEXT; + +ALTER TABLE dhcp4_subnet RENAME client_class TO client_classes; +ALTER TABLE dhcp4_subnet ALTER COLUMN client_classes TYPE TEXT; + +ALTER TABLE dhcp4_pool RENAME client_class TO client_classes; +ALTER TABLE dhcp4_pool ALTER COLUMN client_classes TYPE TEXT; + +ALTER TABLE dhcp6_shared_network RENAME client_class TO client_classes; +ALTER TABLE dhcp6_shared_network ALTER COLUMN client_classes TYPE TEXT; + +ALTER TABLE dhcp6_subnet RENAME client_class TO client_classes; +ALTER TABLE dhcp6_subnet ALTER COLUMN client_classes TYPE TEXT; + +ALTER TABLE dhcp6_pool RENAME client_class TO client_classes; +ALTER TABLE dhcp6_pool ALTER COLUMN client_classes TYPE TEXT; + +ALTER TABLE dhcp6_pd_pool RENAME client_class TO client_classes; +ALTER TABLE dhcp6_pd_pool ALTER COLUMN client_classes TYPE TEXT; + +-- Update the schema version number. +UPDATE schema_version + SET version = '27', minor = '0'; + -- Commit the script transaction. COMMIT; diff --git a/src/share/database/scripts/pgsql/upgrade_026_to_027.sh.in b/src/share/database/scripts/pgsql/upgrade_026_to_027.sh.in new file mode 100644 index 0000000000..c64676eb89 --- /dev/null +++ b/src/share/database/scripts/pgsql/upgrade_026_to_027.sh.in @@ -0,0 +1,70 @@ +#!/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" != "26.0" ]; then + printf 'This script upgrades 26.0 to 27.0. ' + 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 27.0. + +ALTER TABLE dhcp4_shared_network RENAME client_class TO client_classes; +ALTER TABLE dhcp4_shared_network ALTER COLUMN client_classes TYPE TEXT; + +ALTER TABLE dhcp4_subnet RENAME client_class TO client_classes; +ALTER TABLE dhcp4_subnet ALTER COLUMN client_classes TYPE TEXT; + +ALTER TABLE dhcp4_pool RENAME client_class TO client_classes; +ALTER TABLE dhcp4_pool ALTER COLUMN client_classes TYPE TEXT; + +ALTER TABLE dhcp6_shared_network RENAME client_class TO client_classes; +ALTER TABLE dhcp6_shared_network ALTER COLUMN client_classes TYPE TEXT; + +ALTER TABLE dhcp6_subnet RENAME client_class TO client_classes; +ALTER TABLE dhcp6_subnet ALTER COLUMN client_classes TYPE TEXT; + +ALTER TABLE dhcp6_pool RENAME client_class TO client_classes; +ALTER TABLE dhcp6_pool ALTER COLUMN client_classes TYPE TEXT; + +ALTER TABLE dhcp6_pd_pool RENAME client_class TO client_classes; +ALTER TABLE dhcp6_pd_pool ALTER COLUMN client_classes TYPE TEXT; + +-- Update the schema version number. +UPDATE schema_version + SET version = '27', minor = '0'; + +-- Commit the script transaction. +COMMIT; + +EOF |