From: Francis Dupont Date: Fri, 19 May 2023 13:01:49 +0000 (+0200) Subject: [#2867] Checkpoint: schema updated X-Git-Tag: Kea-2.3.8~106 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=63725dc4c99521480b35a57237fc79fb9de4b32e;p=thirdparty%2Fkea.git [#2867] Checkpoint: schema updated --- diff --git a/src/share/database/scripts/mysql/dhcpdb_create.mysql b/src/share/database/scripts/mysql/dhcpdb_create.mysql index 09876c443c..5201c93f7d 100644 --- a/src/share/database/scripts/mysql/dhcpdb_create.mysql +++ b/src/share/database/scripts/mysql/dhcpdb_create.mysql @@ -5300,6 +5300,31 @@ BEGIN END $$ DELIMITER ; +-- Add the binary version of the IPv6 address for v6 BLQ prefix filter. +ALTER TABLE lease6 + ADD COLUMN binaddr BINARY(16) DEFAULT NULL; +CREATE INDEX lease6_by_binaddr ON lease6 (binaddr); + +-- Create table for v6 BLQ by-relay-id. +CREATE TABLE lease6_relay_id ( + extended_info_id INT UNSIGNED NOT NULL AUTO_INCREMENT, + relay_id VARBINARY(130) NOT NULL, + lease_addr BINARY(16) NOT NULL, + PRIMARY KEY (extended_info_id), + INDEX key_lease6_relay_id_by_id (lease6_relay_id, lease_addr ASC), + INDEX key_lease6_relay_id_by_address (lease_addr) +) ENGINE = INNODB; + +-- Create table for v6 BLQ by-remote-id. +CREATE TABLE lease6_remote_id ( + extended_info_id INT UNSIGNED NOT NULL AUTO_INCREMENT, + remote_id VARBINARY(255) NOT NULL, + lease_addr BINARY(16) NOT NULL, + PRIMARY KEY (extended_info_id), + INDEX key_lease6_remote_id_by_id (remote_id, lease_addr ASC), + INDEX key_lease6_remote_id_by_address (lease_addr) +) ENGINE = INNODB; + -- Update the schema version number. UPDATE schema_version SET version = '18', minor = '0'; diff --git a/src/share/database/scripts/mysql/dhcpdb_drop.mysql b/src/share/database/scripts/mysql/dhcpdb_drop.mysql index 0d17890784..fefb44988a 100644 --- a/src/share/database/scripts/mysql/dhcpdb_drop.mysql +++ b/src/share/database/scripts/mysql/dhcpdb_drop.mysql @@ -1,4 +1,4 @@ -# Copyright (C) 2016-2022 Internet Systems Consortium, Inc. ("ISC") +# Copyright (C) 2016-2023 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 @@ -151,3 +151,5 @@ DROP TRIGGER IF EXISTS lease6_ADEL; DROP FUNCTION IF EXISTS checkLease4Limits; DROP FUNCTION IF EXISTS checkLease6Limits; DROP FUNCTION IF EXISTS isJsonSupported; +DROP TABLE IF EXISTS lease6_relay_id; +DROP TABLE IF EXISTS lease6_remote_id; diff --git a/src/share/database/scripts/mysql/upgrade_017_to_018.sh.in b/src/share/database/scripts/mysql/upgrade_017_to_018.sh.in index bc6fc1b34c..6296acdbff 100644 --- a/src/share/database/scripts/mysql/upgrade_017_to_018.sh.in +++ b/src/share/database/scripts/mysql/upgrade_017_to_018.sh.in @@ -188,6 +188,31 @@ BEGIN END $$ DELIMITER ; +-- Add the binary version of the IPv6 address for v6 BLQ prefix filter. +ALTER TABLE lease6 + ADD COLUMN binaddr BINARY(16) DEFAULT NULL; +CREATE INDEX lease6_by_binaddr ON lease6 (binaddr); + +-- Create table for v6 BLQ by-relay-id. +CREATE TABLE lease6_relay_id ( + extended_info_id INT UNSIGNED NOT NULL AUTO_INCREMENT, + relay_id VARBINARY(130) NOT NULL, + lease_addr BINARY(16) NOT NULL, + PRIMARY KEY (extended_info_id), + INDEX key_lease6_relay_id_by_id (lease6_relay_id, lease_addr ASC), + INDEX key_lease6_relay_id_by_address (lease_addr) +) ENGINE = INNODB; + +-- Create table for v6 BLQ by-remote-id. +CREATE TABLE lease6_remote_id ( + extended_info_id INT UNSIGNED NOT NULL AUTO_INCREMENT, + remote_id VARBINARY(255) NOT NULL, + lease_addr BINARY(16) NOT NULL, + PRIMARY KEY (extended_info_id), + INDEX key_lease6_remote_id_by_id (remote_id, lease_addr ASC), + INDEX key_lease6_remote_id_by_address (lease_addr) +) ENGINE = INNODB; + -- Update the schema version number. UPDATE schema_version SET version = '18', minor = '0'; diff --git a/src/share/database/scripts/mysql/wipe_data.sh.in b/src/share/database/scripts/mysql/wipe_data.sh.in index 019300c95a..411818bdc6 100644 --- a/src/share/database/scripts/mysql/wipe_data.sh.in +++ b/src/share/database/scripts/mysql/wipe_data.sh.in @@ -1,6 +1,6 @@ #!/bin/sh -# Copyright (C) 2019-2022 Internet Systems Consortium, Inc. ("ISC") +# Copyright (C) 2019-2023 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 @@ -114,5 +114,7 @@ DELETE FROM lease6_stat; DELETE FROM logs; DELETE FROM lease4_stat_by_client_class; DELETE FROM lease6_stat_by_client_class; +DELETE FROM lease6_relay_id; +DELETE FROM lease6_remote_id; COMMIT; EOF diff --git a/src/share/database/scripts/pgsql/dhcpdb_create.pgsql b/src/share/database/scripts/pgsql/dhcpdb_create.pgsql index f19d7ab2ac..cee8e730e2 100644 --- a/src/share/database/scripts/pgsql/dhcpdb_create.pgsql +++ b/src/share/database/scripts/pgsql/dhcpdb_create.pgsql @@ -5637,6 +5637,26 @@ UPDATE schema_version UPDATE lease6 SET duid = E'\\x000000' WHERE duid = E'\\x00'; +-- Add the binary version of the IPv6 address for v6 BLQ prefix filter. +ALTER TABLE lease6 + ADD COLUMN binaddr BYTEA DEFAULT NULL; + +-- Create table for v6 BLQ by-relay-id. +CREATE TABLE lease6_relay_id ( + extended_info_id SERIAL PRIMARY KEY NOT NULL, + relay_id BYTEA NOT NULL, + lease_addr BYTEA NOT NULL); +CREATE INDEX lease6_relay_id_by_id ON lease6_relay_id (relay_id, lease_addr ASC); +CREATE INDEX lease6_relay_id_by_address ON lease6_relay_id (lease_addr); + +-- Create table for v6 BLQ by-remote-id. +CREATE TABLE lease6_remote_id ( + extended_info_id SERIAL PRIMARY KEY NOT NULL, + remote_id BYTEA NOT NULL, + lease_addr BYTEA NOT NULL); +CREATE INDEX lease6_remote_id_by_id ON lease6_remote_id (remote_id, lease_addr ASC); +CREATE INDEX lease6_remote_id_by_address ON lease6_remote_id (lease_addr); + -- Update the schema version number. UPDATE schema_version SET version = '17', minor = '0'; diff --git a/src/share/database/scripts/pgsql/dhcpdb_drop.pgsql b/src/share/database/scripts/pgsql/dhcpdb_drop.pgsql index 1e88ab9be3..7709bf622c 100644 --- a/src/share/database/scripts/pgsql/dhcpdb_drop.pgsql +++ b/src/share/database/scripts/pgsql/dhcpdb_drop.pgsql @@ -1,4 +1,4 @@ --- Copyright (C) 2016-2022 Internet Systems Consortium. +-- Copyright (C) 2016-2023 Internet Systems Consortium. -- 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 @@ -226,3 +226,7 @@ DROP FUNCTION IF EXISTS checkLease4Limits(user_context TEXT); DROP FUNCTION IF EXISTS checkLease6Limits(user_context TEXT); DROP FUNCTION IF EXISTS isJsonSupported(); DROP FUNCTION IF EXISTS json_cast(json_candidate TEXT); + +-- v6 BLQ cross-tables +DROP TABLE IF EXISTS lease6_relay_id; +DROP TABLE IF EXISTS lease6_remote_id; diff --git a/src/share/database/scripts/pgsql/upgrade_016_to_017.sh.in b/src/share/database/scripts/pgsql/upgrade_016_to_017.sh.in index b3dffaba62..72a1db15bc 100644 --- a/src/share/database/scripts/pgsql/upgrade_016_to_017.sh.in +++ b/src/share/database/scripts/pgsql/upgrade_016_to_017.sh.in @@ -40,6 +40,26 @@ START TRANSACTION; UPDATE lease6 SET duid = E'\\\\x000000' WHERE duid = E'\\\\x00'; +-- Add the binary version of the IPv6 address for v6 BLQ prefix filter. +ALTER TABLE lease6 + ADD COLUMN binaddr BYTEA DEFAULT NULL; + +-- Create table for v6 BLQ by-relay-id. +CREATE TABLE lease6_relay_id ( + extended_info_id SERIAL PRIMARY KEY NOT NULL, + relay_id BYTEA NOT NULL, + lease_addr BYTEA NOT NULL); +CREATE INDEX lease6_relay_id_by_id ON lease6_relay_id (relay_id, lease_addr ASC); +CREATE INDEX lease6_relay_id_by_address ON lease6_relay_id (lease_addr); + +-- Create table for v6 BLQ by-remote-id. +CREATE TABLE lease6_remote_id ( + extended_info_id SERIAL PRIMARY KEY NOT NULL, + remote_id BYTEA NOT NULL, + lease_addr BYTEA NOT NULL); +CREATE INDEX lease6_remote_id_by_id ON lease6_remote_id (remote_id, lease_addr ASC); +CREATE INDEX lease6_remote_id_by_address ON lease6_remote_id (lease_addr); + -- Update the schema version number. UPDATE schema_version SET version = '17', minor = '0'; diff --git a/src/share/database/scripts/pgsql/wipe_data.sh.in b/src/share/database/scripts/pgsql/wipe_data.sh.in index 4996c91c7b..79a0e3f154 100644 --- a/src/share/database/scripts/pgsql/wipe_data.sh.in +++ b/src/share/database/scripts/pgsql/wipe_data.sh.in @@ -1,6 +1,6 @@ #!/bin/sh -# Copyright (C) 2019-2022 Internet Systems Consortium, Inc. ("ISC") +# Copyright (C) 2019-2023 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 @@ -113,5 +113,8 @@ DELETE FROM dhcp6_client_class_server; DELETE FROM dhcp6_client_class; DELETE FROM dhcp6_server WHERE tag != 'all'; -- preserve the special tag +DELETE FROM lease6_relay_id; +DELETE FROM lease6_remote_id; + COMMIT; EOF