Skip to content

Commit 59ef648

Browse files
committed
[#3683] Checkpoint: update after rebase
1 parent 970e625 commit 59ef648

15 files changed

+168
-14
lines changed

configure.ac

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1825,6 +1825,8 @@ AC_CONFIG_FILES([src/share/database/scripts/mysql/upgrade_026_to_027.sh],
18251825
[chmod +x src/share/database/scripts/mysql/upgrade_026_to_027.sh])
18261826
AC_CONFIG_FILES([src/share/database/scripts/mysql/upgrade_027_to_028.sh],
18271827
[chmod +x src/share/database/scripts/mysql/upgrade_027_to_028.sh])
1828+
AC_CONFIG_FILES([src/share/database/scripts/mysql/upgrade_028_to_029.sh],
1829+
[chmod +x src/share/database/scripts/mysql/upgrade_028_to_029.sh])
18281830
AC_CONFIG_FILES([src/share/database/scripts/mysql/wipe_data.sh],
18291831
[chmod +x src/share/database/scripts/mysql/wipe_data.sh])
18301832
AC_CONFIG_FILES([src/share/database/scripts/pgsql/Makefile])
@@ -1894,6 +1896,8 @@ AC_CONFIG_FILES([src/share/database/scripts/pgsql/upgrade_026_to_027.sh],
18941896
[chmod +x src/share/database/scripts/pgsql/upgrade_026_to_027.sh])
18951897
AC_CONFIG_FILES([src/share/database/scripts/pgsql/upgrade_027_to_028.sh],
18961898
[chmod +x src/share/database/scripts/pgsql/upgrade_027_to_028.sh])
1899+
AC_CONFIG_FILES([src/share/database/scripts/pgsql/upgrade_028_to_029.sh],
1900+
[chmod +x src/share/database/scripts/pgsql/upgrade_028_to_029.sh])
18971901
AC_CONFIG_FILES([src/share/database/scripts/pgsql/wipe_data.sh],
18981902
[chmod +x src/share/database/scripts/pgsql/wipe_data.sh])
18991903
AC_CONFIG_FILES([src/share/yang/Makefile])

src/bin/admin/tests/mysql_tests.sh.in

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1020,6 +1020,9 @@ mysql_upgrade_27_to_28_test() {
10201020
check_table_column ddns_ttl dhcp6_subnet
10211021
check_table_column ddns_ttl_min dhcp6_subnet
10221022
check_table_column ddns_ttl_max dhcp6_subnet
1023+
}
1024+
1025+
mysql_upgrade_28_to_29_test() {
10231026

10241027
# check registered were added tp lease_state
10251028
qry="SELECT name FROM lease_state WHERE state = 4"
@@ -1050,7 +1053,7 @@ mysql_upgrade_test() {
10501053

10511054
# Verify that the upgraded schema reports the latest version.
10521055
version=$("${kea_admin}" db-version mysql -u "${db_user}" -p "${db_password}" -n "${db_name}" -d "${db_scripts_dir}")
1053-
assert_str_eq "28.0" "${version}" "Expected kea-admin to return %s, returned value was %s"
1056+
assert_str_eq "29.0" "${version}" "Expected kea-admin to return %s, returned value was %s"
10541057

10551058
# Let's check that the new tables are indeed there.
10561059

@@ -1731,6 +1734,9 @@ SET @disable_audit = 0"
17311734
# Check upgrade from 27.0 to 28.0.
17321735
mysql_upgrade_27_to_28_test
17331736

1737+
# Check upgrade from 28.0 to 29.0.
1738+
mysql_upgrade_28_to_29_test
1739+
17341740
# Let's wipe the whole database
17351741
mysql_wipe
17361742

src/bin/admin/tests/pgsql_tests.sh.in

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,7 @@ pgsql_db_version_test() {
158158
run_command \
159159
"${kea_admin}" db-version pgsql -u "${db_user}" -p "${db_password}" -n "${db_name}"
160160
version="${OUTPUT}"
161-
assert_str_eq "28.0" "${version}" "Expected kea-admin to return %s, returned value was %s"
161+
assert_str_eq "29.0" "${version}" "Expected kea-admin to return %s, returned value was %s"
162162

163163
# Let's wipe the whole database
164164
pgsql_wipe
@@ -1111,6 +1111,9 @@ pgsql_upgrade_27_to_28_test() {
11111111
check_table_column ddns_ttl dhcp6_subnet
11121112
check_table_column ddns_ttl_min dhcp6_subnet
11131113
check_table_column ddns_ttl_max dhcp6_subnet
1114+
}
1115+
1116+
pgsql_upgrade_28_to_29_test() {
11141117

11151118
# check registered were added tp lease_state
11161119
query="SELECT name FROM lease_state WHERE state = 4"
@@ -1138,7 +1141,7 @@ pgsql_upgrade_test() {
11381141

11391142
# Verify upgraded schema reports the latest version.
11401143
version=$("${kea_admin}" db-version pgsql -u "${db_user}" -p "${db_password}" -n "${db_name}" -d "${db_scripts_dir}")
1141-
assert_str_eq "28.0" "${version}" 'Expected kea-admin to return %s, returned value was %s'
1144+
assert_str_eq "29.0" "${version}" 'Expected kea-admin to return %s, returned value was %s'
11421145

11431146
# Check 1.0 to 2.0 upgrade
11441147
pgsql_upgrade_1_0_to_2_0_test
@@ -1215,6 +1218,9 @@ pgsql_upgrade_test() {
12151218
# Check 27 to 28 upgrade
12161219
pgsql_upgrade_27_to_28_test
12171220

1221+
# Check 28 to 29 upgrade
1222+
pgsql_upgrade_28_to_29_test
1223+
12181224
# Let's wipe the whole database
12191225
pgsql_wipe
12201226

src/lib/mysql/mysql_constants.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ const int MLM_MYSQL_FETCH_FAILURE = 0;
5252

5353
/// @name Current database schema version values.
5454
//@{
55-
const uint32_t MYSQL_SCHEMA_VERSION_MAJOR = 28;
55+
const uint32_t MYSQL_SCHEMA_VERSION_MAJOR = 29;
5656
const uint32_t MYSQL_SCHEMA_VERSION_MINOR = 0;
5757

5858
//@}

src/lib/pgsql/pgsql_connection.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ namespace isc {
1818
namespace db {
1919

2020
/// @brief Define the PostgreSQL backend version.
21-
const uint32_t PGSQL_SCHEMA_VERSION_MAJOR = 28;
21+
const uint32_t PGSQL_SCHEMA_VERSION_MAJOR = 29;
2222
const uint32_t PGSQL_SCHEMA_VERSION_MINOR = 0;
2323

2424
// Maximum number of parameters that can be used a statement

src/share/database/scripts/mysql/.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,4 +36,5 @@
3636
/upgrade_025_to_026.sh
3737
/upgrade_026_to_027.sh
3838
/upgrade_027_to_028.sh
39+
/upgrade_028_to_029.sh
3940
/wipe_data.sh

src/share/database/scripts/mysql/Makefile.am

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ mysql_SCRIPTS += upgrade_024_to_025.sh
4747
mysql_SCRIPTS += upgrade_025_to_026.sh
4848
mysql_SCRIPTS += upgrade_026_to_027.sh
4949
mysql_SCRIPTS += upgrade_027_to_028.sh
50+
mysql_SCRIPTS += upgrade_028_to_029.sh
5051
mysql_SCRIPTS += wipe_data.sh
5152

5253
DISTCLEANFILES = ${mysql_SCRIPTS}

src/share/database/scripts/mysql/dhcpdb_create.mysql

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6157,14 +6157,22 @@ ALTER TABLE dhcp6_subnet
61576157
ADD COLUMN ddns_ttl_min INT(10) DEFAULT NULL,
61586158
ADD COLUMN ddns_ttl_max INT(10) DEFAULT NULL;
61596159

6160+
-- Update the schema version number.
6161+
UPDATE schema_version
6162+
SET version = '28', minor = '0';
6163+
6164+
-- This line concludes the schema upgrade to version 28.0.
6165+
6166+
-- This line starts the schema upgrade to version 29.0.
6167+
61606168
-- New lease state for address registration
61616169
INSERT INTO lease_state VALUES (4, 'registered');
61626170

61636171
-- Update the schema version number.
61646172
UPDATE schema_version
6165-
SET version = '28', minor = '0';
6173+
SET version = '29', minor = '0';
61666174

6167-
-- This line concludes the schema upgrade to version 28.0.
6175+
-- This line concludes the schema upgrade to version 29.0.
61686176

61696177
# Notes:
61706178
#

src/share/database/scripts/mysql/upgrade_027_to_028.sh.in

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -80,9 +80,6 @@ ALTER TABLE dhcp6_subnet
8080
ADD COLUMN ddns_ttl_min INT(10) DEFAULT NULL,
8181
ADD COLUMN ddns_ttl_max INT(10) DEFAULT NULL;
8282
83-
-- New lease state for address registration
84-
INSERT INTO lease_state VALUES (4, 'registered');
85-
8683
-- Update the schema version number.
8784
UPDATE schema_version
8885
SET version = '28', minor = '0';
Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
#!/bin/sh
2+
3+
# Copyright (C) 2024-2025 Internet Systems Consortium, Inc. ("ISC")
4+
#
5+
# This Source Code Form is subject to the terms of the Mozilla Public
6+
# License, v. 2.0. If a copy of the MPL was not distributed with this
7+
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
8+
9+
# Exit with error if commands exit with non-zero and if undefined variables are
10+
# used.
11+
set -eu
12+
13+
# shellcheck disable=SC2034
14+
# SC2034: ... appears unused. Verify use (or export if used externally).
15+
prefix="@prefix@"
16+
17+
# Include utilities based on location of this script. Check for sources first,
18+
# so that the unexpected situations with weird paths fall on the default
19+
# case of installed.
20+
script_path=$(cd "$(dirname "${0}")" && pwd)
21+
if test "${script_path}" = "@abs_top_builddir@/src/share/database/scripts/mysql"; then
22+
# shellcheck source=./src/bin/admin/admin-utils.sh.in
23+
. "@abs_top_builddir@/src/bin/admin/admin-utils.sh"
24+
else
25+
# shellcheck source=./src/bin/admin/admin-utils.sh.in
26+
. "@datarootdir@/@PACKAGE_NAME@/scripts/admin-utils.sh"
27+
fi
28+
29+
# Check version.
30+
version=$(mysql_version "${@}")
31+
if test "${version}" != "27.0"; then
32+
printf 'This script upgrades 28.0 to 29.0. '
33+
printf 'Reported version is %s. Skipping upgrade.\n' "${version}"
34+
exit 0
35+
fi
36+
37+
# Get the schema name from database argument. We need this to
38+
# query information_schema for the right database.
39+
for arg in "${@}"
40+
do
41+
if ! printf '%s' "${arg}" | grep -Eq -- '^--'
42+
then
43+
schema="$arg"
44+
break
45+
fi
46+
done
47+
48+
# Make sure we have the schema.
49+
if [ -z "$schema" ]
50+
then
51+
printf "Could not find database schema name in cmd line args: %s\n" "${*}"
52+
exit 255
53+
fi
54+
55+
mysql "$@" <<EOF
56+
57+
-- This line starts the schema upgrade to version 29.0.
58+
59+
-- New lease state for address registration
60+
INSERT INTO lease_state VALUES (4, 'registered');
61+
62+
-- Update the schema version number.
63+
UPDATE schema_version
64+
SET version = '29', minor = '0';
65+
66+
-- This line concludes the schema upgrade to version 29.0.
67+
68+
EOF

src/share/database/scripts/pgsql/.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,4 +31,5 @@
3131
/upgrade_025_to_026.sh
3232
/upgrade_026_to_027.sh
3333
/upgrade_027_to_028.sh
34+
/upgrade_028_to_029.sh
3435
/wipe_data.sh

src/share/database/scripts/pgsql/Makefile.am

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ pgsql_SCRIPTS += upgrade_024_to_025.sh
4242
pgsql_SCRIPTS += upgrade_025_to_026.sh
4343
pgsql_SCRIPTS += upgrade_026_to_027.sh
4444
pgsql_SCRIPTS += upgrade_027_to_028.sh
45+
pgsql_SCRIPTS += upgrade_028_to_029.sh
4546
pgsql_SCRIPTS += wipe_data.sh
4647

4748
DISTCLEANFILES = ${pgsql_SCRIPTS}

src/share/database/scripts/pgsql/dhcpdb_create.pgsql

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6625,6 +6625,17 @@ UPDATE schema_version
66256625

66266626
-- This line concludes the schema upgrade to version 28.0.
66276627

6628+
-- This line starts the schema upgrade to version 29.0.
6629+
6630+
-- New lease state for address registration
6631+
INSERT INTO lease_state VALUES (4, 'registered');
6632+
6633+
-- Update the schema version number.
6634+
UPDATE schema_version
6635+
SET version = '29', minor = '0';
6636+
6637+
-- This line concludes the schema upgrade to version 29.0.
6638+
66286639
-- Commit the script transaction.
66296640
COMMIT;
66306641

src/share/database/scripts/pgsql/upgrade_027_to_028.sh.in

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -66,10 +66,6 @@ ALTER TABLE dhcp6_subnet
6666
-- New lease state for address registration
6767
INSERT INTO lease_state VALUES (4, 'registered');
6868
69-
-- Update the schema version number.
70-
UPDATE schema_version
71-
SET version = '28', minor = '0';
72-
7369
-- This line concludes the schema upgrade to version 28.0.
7470
7571
-- Commit the script transaction.
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
#!/bin/sh
2+
3+
# Copyright (C) 2024 Internet Systems Consortium, Inc. ("ISC")
4+
#
5+
# This Source Code Form is subject to the terms of the Mozilla Public
6+
# License, v. 2.0. If a copy of the MPL was not distributed with this
7+
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
8+
9+
# Exit with error if commands exit with non-zero and if undefined variables are
10+
# used.
11+
set -eu
12+
13+
# shellcheck disable=SC2034
14+
# SC2034: ... appears unused. Verify use (or export if used externally).
15+
prefix="@prefix@"
16+
17+
# Include utilities based on location of this script. Check for sources first,
18+
# so that the unexpected situations with weird paths fall on the default
19+
# case of installed.
20+
script_path=$(cd "$(dirname "${0}")" && pwd)
21+
if test "${script_path}" = "@abs_top_builddir@/src/share/database/scripts/pgsql"; then
22+
# shellcheck source=./src/bin/admin/admin-utils.sh.in
23+
. "@abs_top_builddir@/src/bin/admin/admin-utils.sh"
24+
else
25+
# shellcheck source=./src/bin/admin/admin-utils.sh.in
26+
. "@datarootdir@/@PACKAGE_NAME@/scripts/admin-utils.sh"
27+
fi
28+
29+
VERSION=$(pgsql_version "$@")
30+
31+
if [ "$VERSION" != "28.0" ]; then
32+
printf 'This script upgrades 28.0 to 29.0. '
33+
printf 'Reported version is %s. Skipping upgrade.\n' "${VERSION}"
34+
exit 0
35+
fi
36+
37+
psql "$@" >/dev/null <<EOF
38+
START TRANSACTION;
39+
40+
-- This line starts the schema upgrade to version 29.0.
41+
42+
-- New lease state for address registration
43+
INSERT INTO lease_state VALUES (4, 'registered');
44+
45+
-- Update the schema version number.
46+
UPDATE schema_version
47+
SET version = '29', minor = '0';
48+
49+
-- This line concludes the schema upgrade to version 29.0.
50+
51+
-- Commit the script transaction.
52+
COMMIT;
53+
54+
EOF

0 commit comments

Comments
 (0)