]> git.ipfire.org Git - thirdparty/kea.git/commitdiff
[#3592] Update schemas
authorThomas Markwalder <tmark@isc.org>
Fri, 1 Nov 2024 17:43:06 +0000 (13:43 -0400)
committerThomas Markwalder <tmark@isc.org>
Tue, 26 Nov 2024 17:19:56 +0000 (17:19 +0000)
src/share/database/scripts/mysql/upgrade_026_to_027.sh.in
src/share/database/scripts/pgsql/upgrade_026_to_027.sh.in
    - new upgrade scripts

configure.ac
src/share/database/scripts/mysql/.gitignore
src/share/database/scripts/mysql/Makefile.am
src/share/database/scripts/pgsql/.gitignore
src/share/database/scripts/pgsql/Makefile.am
    added new upgrade scripts

src/bin/admin/tests/mysql_tests.sh.in
    updated
    mysql_upgrade_26_to_27_test()  - new test

src/bin/admin/tests/pgsql_tests.sh.in
    updated
    pgsql_upgrade_26_to_27_test() - new test

src/lib/mysql/mysql_constants.h
src/lib/pgsql/pgsql_connection.h
    updated schema version

src/share/database/scripts/mysql/dhcpdb_create.mysql
src/share/database/scripts/pgsql/dhcpdb_create.pgsql
    change client_class columns

13 files changed:
configure.ac
src/bin/admin/tests/mysql_tests.sh.in
src/bin/admin/tests/pgsql_tests.sh.in
src/lib/mysql/mysql_constants.h
src/lib/pgsql/pgsql_connection.h
src/share/database/scripts/mysql/.gitignore
src/share/database/scripts/mysql/Makefile.am
src/share/database/scripts/mysql/dhcpdb_create.mysql
src/share/database/scripts/mysql/upgrade_026_to_027.sh.in [new file with mode: 0644]
src/share/database/scripts/pgsql/.gitignore
src/share/database/scripts/pgsql/Makefile.am
src/share/database/scripts/pgsql/dhcpdb_create.pgsql
src/share/database/scripts/pgsql/upgrade_026_to_027.sh.in [new file with mode: 0644]

index 791b675ffc2eb1b10c03d7866980a6bbdc9927b2..27ee28f31629cc8f0d4b1a1b3b84765d27cf0355 100644 (file)
@@ -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])
index bd936f8aa934cca7a48b47260b087787cffbf82d..7150c8b2fdff5e0aa132ea5ab104761f349ee48b 100644 (file)
@@ -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
 
index 7fa4443d385aadde23bb52dfda60e1214055cd3e..fd5c200e1829b27c3f7c980b6952089cbc055664 100644 (file)
@@ -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
 
index 8cdcbea4eff4a8cf8e0943ed9a963458c44ebe80..7d2d640730c92fb161c9325f311fafe59b9ca4b4 100644 (file)
@@ -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;
 
 //@}
index 5667dd79276aef77b689d436d67ed409c253076c..73cad7142663e1306afc6527b4a2abf0afb33e26 100644 (file)
@@ -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
index 0b4c5489c90b24a0f76dcdbf28ef7ca703525f7c..e67addfeb89b035501fa90fd5b4600cc110e2c45 100644 (file)
@@ -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
index 7bcaba65026ef1c8a049ce4fd79343a2b437e272..bedb59088b73960ed42117f9a83108a1e53125a7 100644 (file)
@@ -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}
index 723d26e9663151fb06a692b7b9fb073476fdc65d..a212dc8cf95825d08da41aa0d12243353fd3cfb8 100644 (file)
@@ -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 (file)
index 0000000..552eb17
--- /dev/null
@@ -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
index ae7b60b0351c7e9da389a008bf7f4482342fcb3c..f77ce459a05ccb6dda9afe5149a936f1ec9a47e5 100644 (file)
@@ -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
index fd0ef79f3589b066ca3bdde7786cecf9f664670c..25614f3b3acab8fca281d3b1b750eea068f4e686 100644 (file)
@@ -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}
index a25a8000246d1f89aa1f921919c3a01facadd372..87c2448a5b58645a3f024a760300c8277c846699 100644 (file)
@@ -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 (file)
index 0000000..c64676e
--- /dev/null
@@ -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