summaryrefslogtreecommitdiffstats
path: root/src/share/database
diff options
context:
space:
mode:
authorThomas Markwalder <tmark@isc.org>2024-04-18 20:33:11 +0200
committerThomas Markwalder <tmark@isc.org>2024-04-22 13:24:32 +0200
commitf04c101f64bbb3ee3bc7d16f78244bffad660a48 (patch)
tree5956fe0098ec598d1b63fe97fabcb138f26bfbdb /src/share/database
parent[#3125] Add ChangeLog for #3125 (diff)
downloadkea-f04c101f64bbb3ee3bc7d16f78244bffad660a48.tar.xz
kea-f04c101f64bbb3ee3bc7d16f78244bffad660a48.zip
[#2957] Fix dhcp4_server_modification_ts index
src/share/database/scripts/pgsql/upgrade_020_to_021.sh.in - new file, corrects dhcp4_server_modifcation_ts index configure.ac added src/share/database/scripts/pgsql/upgrade_020_to_021.sh src/bin/admin/tests/pgsql_tests.sh.in Added pgsql_upgrade_20_to_21_test() src/lib/pgsql/pgsql_connection.h Updated schema version src/share/database/scripts/pgsql/.gitignore src/share/database/scripts/pgsql/Makefile.am Added upgrade_020_to_021.sh src/share/database/scripts/pgsql/dhcpdb_create.pgsql Added correction of dhcp4_server_modifcation_ts index
Diffstat (limited to 'src/share/database')
-rw-r--r--src/share/database/scripts/pgsql/.gitignore1
-rw-r--r--src/share/database/scripts/pgsql/Makefile.am1
-rw-r--r--src/share/database/scripts/pgsql/dhcpdb_create.pgsql12
-rw-r--r--src/share/database/scripts/pgsql/upgrade_020_to_021.sh.in55
4 files changed, 69 insertions, 0 deletions
diff --git a/src/share/database/scripts/pgsql/.gitignore b/src/share/database/scripts/pgsql/.gitignore
index b4156d8989..b8e0b819f2 100644
--- a/src/share/database/scripts/pgsql/.gitignore
+++ b/src/share/database/scripts/pgsql/.gitignore
@@ -23,4 +23,5 @@
/upgrade_017_to_018.sh
/upgrade_018_to_019.sh
/upgrade_019_to_020.sh
+/upgrade_020_to_021.sh
/wipe_data.sh
diff --git a/src/share/database/scripts/pgsql/Makefile.am b/src/share/database/scripts/pgsql/Makefile.am
index 32685c44e5..a7049a4c96 100644
--- a/src/share/database/scripts/pgsql/Makefile.am
+++ b/src/share/database/scripts/pgsql/Makefile.am
@@ -34,6 +34,7 @@ pgsql_SCRIPTS += upgrade_016_to_017.sh
pgsql_SCRIPTS += upgrade_017_to_018.sh
pgsql_SCRIPTS += upgrade_018_to_019.sh
pgsql_SCRIPTS += upgrade_019_to_020.sh
+pgsql_SCRIPTS += upgrade_020_to_021.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 36502129f3..bececdcd76 100644
--- a/src/share/database/scripts/pgsql/dhcpdb_create.pgsql
+++ b/src/share/database/scripts/pgsql/dhcpdb_create.pgsql
@@ -6325,6 +6325,18 @@ UPDATE schema_version
-- This line concludes the schema upgrade to version 20.0.
+-- This line starts the schema upgrade to version 21.0.
+
+-- Correct dhcp4_server_modifcation_ts to index the dhcp4_server table.
+DROP INDEX dhcp4_server_modification_ts;
+CREATE INDEX dhcp4_server_modification_ts ON dhcp4_server (modification_ts);
+
+-- Update the schema version number.
+UPDATE schema_version
+ SET version = '21', minor = '0';
+
+-- This line concludes the schema upgrade to version 21.0.
+
-- Commit the script transaction.
COMMIT;
diff --git a/src/share/database/scripts/pgsql/upgrade_020_to_021.sh.in b/src/share/database/scripts/pgsql/upgrade_020_to_021.sh.in
new file mode 100644
index 0000000000..65b2e0496e
--- /dev/null
+++ b/src/share/database/scripts/pgsql/upgrade_020_to_021.sh.in
@@ -0,0 +1,55 @@
+#!/bin/sh
+
+# Copyright (C) 2023-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" != "20.0" ]; then
+ printf 'This script upgrades 20.0 to 21.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 21.0.
+
+-- Correct dhcp4_server_modifcation_ts to index the dhcp4_server table.
+DROP INDEX dhcp4_server_modification_ts;
+CREATE INDEX dhcp4_server_modification_ts ON dhcp4_server (modification_ts);
+
+-- Update the schema version number.
+UPDATE schema_version
+ SET version = '21', minor = '0';
+
+-- This line concludes the schema upgrade to version 21.0.
+
+-- Commit the script transaction.
+COMMIT;
+
+EOF