diff options
author | Thomas Markwalder <tmark@isc.org> | 2024-11-01 18:43:06 +0100 |
---|---|---|
committer | Thomas Markwalder <tmark@isc.org> | 2024-11-26 18:19:56 +0100 |
commit | 09c3b5aa68bd2afd50f3204b8cb41d1703134bfe (patch) | |
tree | 8ad0295dce437c6b0485eefe01df57e21f46b2a9 /src/share/database/scripts | |
parent | [#3582] Update kea-dhcp6 parsing and UTs (diff) | |
download | kea-09c3b5aa68bd2afd50f3204b8cb41d1703134bfe.tar.xz kea-09c3b5aa68bd2afd50f3204b8cb41d1703134bfe.zip |
[#3592] Update schemas
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
Diffstat (limited to 'src/share/database/scripts')
-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 |
8 files changed, 215 insertions, 0 deletions
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 |