version=$("${kea_admin}" db-version mysql -u "${db_user}" -p "${db_password}" -n "${db_name}" -d "${db_scripts_dir}")
assert_str_eq "1.0" "${version}" "Expected kea-admin to return %s, returned value was %s"
- # Ok, we have a 1.0 database. Let's upgrade it to the latest version.
+ # Let's upgrade it to the latest version.
run_command \
"${kea_admin}" db-upgrade mysql -u "${db_user}" -p "${db_password}" -n "${db_name}" -d "${db_scripts_dir}"
assert_eq 0 "${EXIT_CODE}" "kea-admin db-upgrade mysql failed, expected %d, returned non-zero status code %d\n"
# 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 "17.0" "${version}" "Expected kea-admin to return %s, returned value was %s"
+ assert_str_eq "18.0" "${version}" "Expected kea-admin to return %s, returned value was %s"
# Let's check that the new tables are indeed there.
insert into lease6 (address, lease_type, subnet_id, state) values (666,1,40,2);"
run_statement "insert v6 leases" "$qry"
- # Ok, we have a 4.0 database with leases. Let's upgrade it to the latest version.
+ # Let's upgrade it to the latest version.
run_command \
"${kea_admin}" db-upgrade mysql -u "${db_user}" -p "${db_password}" -n "${db_name}" -d "${db_scripts_dir}"
mysql_wipe
# We need to create an older database with lease data so we can
- # verify the upgrade mechanisms which convert reservations values
+ # verify the upgrade mechanisms which convert reservation values
#
# Initialize database to schema 1.0.
mysql -u"${db_user}" -p"${db_password}" "${db_name}" < "@abs_top_srcdir@/src/bin/admin/tests/dhcpdb_create_1.0.mysql"
run_statement "insert v6 leases" "$sql"
- # Ok, we have a 14.0 database with leases. Let's upgrade it to latest version.
+ # Let's upgrade it to the latest version.
run_command \
"${kea_admin}" db-upgrade mysql -u "${db_user}" -p "${db_password}" -n "${db_name}" -d "${db_scripts_dir}"
run_command \
"${kea_admin}" db-version pgsql -u "${db_user}" -p "${db_password}" -n "${db_name}"
version="${OUTPUT}"
- assert_str_eq "16.0" "${version}" "Expected kea-admin to return %s, returned value was %s"
+ assert_str_eq "17.0" "${version}" "Expected kea-admin to return %s, returned value was %s"
# Let's wipe the whole database
pgsql_wipe
pgsql_execute_script "@abs_top_srcdir@/src/bin/admin/tests/dhcpdb_create_1.0.pgsql"
assert_eq 0 "${EXIT_CODE}" "cannot initialize the database, expected exit code: %d, actual: %d"
- # Ok, we have a 1.0 database. Let's upgrade it to the latest version.
+ # Let's upgrade it to the latest version.
run_command \
"${kea_admin}" db-upgrade pgsql -u "${db_user}" -p "${db_password}" -n "${db_name}" -d "${db_scripts_dir}"
assert_eq 0 "${EXIT_CODE}" "db-upgrade failed, expected exit code: %d, actual: %d"
# 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 "16.0" "${version}" 'Expected kea-admin to return %s, returned value was %s'
+ assert_str_eq "17.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
insert into lease6 (address, lease_type, subnet_id, state) values (666,1,40,2);"
run_statement "insert v6 leases" "$qry"
- # Ok, we have a 2.0 database with leases. Let's upgrade it to latest version.
+ # Let's upgrade it to the latest version.
run_command \
"${kea_admin}" db-upgrade pgsql -u "${db_user}" -p "${db_password}" -n "${db_name}" -d "${db_scripts_dir}"
run_statement "insert options" "$qry"
- # Ok, we have a 4.0 database with hosts and options. Let's upgrade it to latest version.
+ # Let's upgrade it to the latest version.
run_command \
"${kea_admin}" db-upgrade pgsql -u "${db_user}" -p "${db_password}" -n "${db_name}" -d "${db_scripts_dir}"
run_statement "insert v6 leases" "$qry"
- # Ok, we have a 14.0 database with leases. Let's upgrade it to latest version.
+ # Let's upgrade it to the latest version.
run_command \
"${kea_admin}" db-upgrade pgsql -u "${db_user}" -p "${db_password}" -n "${db_name}" -d "${db_scripts_dir}"
ClientHandler::lookup(const ClientIdPtr& client_id) {
// Sanity check.
if (!client_id) {
- isc_throw(InvalidParameter, "null duid in ClientHandler::lookup");
+ isc_throw(InvalidParameter, "null client-id in ClientHandler::lookup");
}
auto it = clients_client_id_.find(client_id->getClientId());
// We check if the decline process was successful by checking if the
// lease is in the database and what is its state.
if (expected_result == SHOULD_PASS) {
- EXPECT_EQ(Lease::STATE_DECLINED, lease->state_);
+ ASSERT_EQ(Lease::STATE_DECLINED, lease->state_);
ASSERT_TRUE(lease->hwaddr_);
ASSERT_TRUE(lease->hwaddr_->hwaddr_.empty());
// The decline succeeded, so the declined-addresses statistic should
// be increased by one
- EXPECT_EQ(after, before + 1);
-
- EXPECT_EQ(after_global, before_global + 1);
+ ASSERT_EQ(after, before + 1);
+ ASSERT_EQ(after_global, before_global + 1);
} else {
// the decline was supposed, to be rejected.
- EXPECT_EQ(Lease::STATE_DEFAULT, lease->state_);
+ ASSERT_EQ(Lease::STATE_DEFAULT, lease->state_);
ASSERT_TRUE(lease->hwaddr_);
ASSERT_FALSE(lease->hwaddr_->hwaddr_.empty());
// The decline failed, so the declined-addresses should be the same
// as before
- EXPECT_EQ(before, after);
- EXPECT_EQ(before_global, after_global);
+ ASSERT_EQ(before, after);
+ ASSERT_EQ(before_global, after_global);
}
}
// We check if the decline process was successful by checking if the
// lease is in the database and what is its state.
if (expected_result == SHOULD_PASS) {
- EXPECT_EQ(Lease::STATE_DECLINED, lease->state_);
+ ASSERT_EQ(Lease::STATE_DECLINED, lease->state_);
ASSERT_FALSE(lease->hwaddr_);
ASSERT_TRUE(lease->duid_);
// The decline succeeded, so the declined-addresses statistic should
// be increased by one
- EXPECT_EQ(after, before + 1);
- EXPECT_EQ(after_global, before_global + 1);
+ ASSERT_EQ(after, before + 1);
+ ASSERT_EQ(after_global, before_global + 1);
} else {
// the decline was supposed, to be rejected.
- EXPECT_EQ(Lease::STATE_DEFAULT, lease->state_);
+ ASSERT_EQ(Lease::STATE_DEFAULT, lease->state_);
ASSERT_TRUE(lease->hwaddr_);
ASSERT_TRUE(lease->duid_);
// The decline failed, so the declined-addresses should be the same
// as before
- EXPECT_EQ(before, after);
- EXPECT_EQ(before_global, after_global);
+ ASSERT_EQ(before, after);
+ ASSERT_EQ(before_global, after_global);
}
}
public:
/// @brief minimum duid size
- /// The minimal DUID size specified in RFC 8415 is 1.
+ /// The minimal DUID size specified in RFC 8415, section 11.1 is 3:
+ /// 2 fixed octets for the type + 1 minimum octet for the value.
static constexpr size_t MIN_DUID_LEN = IdentifierType::getMinSize();
/// @brief maximum duid size
- /// As defined in RFC 8415, section 11.1
+ /// The maximum DUID size specified in RFC 8415, section 11.1 is 130:
+ /// 2 fixed octets for the type + 128 maximum octets for the value.
static constexpr size_t MAX_DUID_LEN = IdentifierType::getMaxSize();
/// @brief specifies DUID type
/// @todo Rewrite this once support for client-identifier option
/// is implemented (ticket 1228?)
if (hlen > MAX_CHADDR_LEN) {
- isc_throw(OutOfRange, "Hardware address (len=" << hlen
- << " too long. Max " << MAX_CHADDR_LEN << " supported.");
+ isc_throw(OutOfRange, "Hardware address (len=" << static_cast<uint32_t>(hlen)
+ << ") too long. Max " << MAX_CHADDR_LEN << " supported.");
} else if (mac_addr.empty() && (hlen > 0) ) {
isc_throw(OutOfRange, "Invalid HW Address specified");
// Create DUID.
std::vector<uint8_t> duid_data(DUID::MIN_DUID_LEN, 1);
- DUID duid(&duid_data[0], duid_data.size());
+ DUID duid(duid_data.data(), duid_data.size());
// Create DHCID.
ASSERT_NO_THROW(dhcid.fromDUID(duid, wire_fqdn_));
/// @name Current database schema version values.
//@{
-const uint32_t MYSQL_SCHEMA_VERSION_MAJOR = 17;
+const uint32_t MYSQL_SCHEMA_VERSION_MAJOR = 18;
const uint32_t MYSQL_SCHEMA_VERSION_MINOR = 0;
//@}
namespace db {
/// @brief Define the PostgreSQL backend version.
-const uint32_t PGSQL_SCHEMA_VERSION_MAJOR = 16;
+const uint32_t PGSQL_SCHEMA_VERSION_MAJOR = 17;
const uint32_t PGSQL_SCHEMA_VERSION_MINOR = 0;
// Maximum number of parameters that can be used a statement
# Hardware address extracted from docsis options
INSERT INTO lease_hwaddr_source VALUES (64, 'HWADDR_SOURCE_DOCSIS');
-# Update the schema version number
+# Update the schema version number.
UPDATE schema_version
SET version = '2', minor = '0';
$$
DELIMITER ;
-# Update the schema version number
+# Update the schema version number.
UPDATE schema_version
SET version = '3', minor = '0';
END $$
DELIMITER ;
-# Update the schema version number
+# Update the schema version number.
UPDATE schema_version
SET version = '4', minor = '0';
# foreign key constraint between lease6 and lease_hardware_source
INSERT INTO lease_hwaddr_source VALUES (0, 'HWADDR_SOURCE_UNKNOWN');
-# Update the schema version number
+# Update the schema version number.
UPDATE schema_version
SET version = '4', minor = '1';
# This line concludes the schema upgrade to version 4.1.
-# This line starts the schema upgrade to version 5.
+# This line starts the schema upgrade to version 5.0.
# Update index used for searching DHCPv4 reservations by identifier and subnet id.
# This index is now unique (to prevent duplicates) and includes DHCPv4 subnet
ALTER TABLE hosts ADD COLUMN dhcp4_server_hostname VARCHAR(64) NULL;
ALTER TABLE hosts ADD COLUMN dhcp4_boot_file_name VARCHAR(128) NULL;
-# Update the schema version number
+# Update the schema version number.
UPDATE schema_version
SET version = '5', minor = '0';
$$
DELIMITER ;
-# Update the schema version number
+# Update the schema version number.
UPDATE schema_version
SET version = '5', minor = '1';
ALTER TABLE dhcp4_options MODIFY dhcp4_subnet_id INT UNSIGNED;
ALTER TABLE dhcp6_options MODIFY dhcp6_subnet_id INT UNSIGNED;
-# Update the schema version number
+# Update the schema version number.
UPDATE schema_version
SET version = '5', minor = '2';
END $$
DELIMITER ;
-# Update the schema version number
+# Update the schema version number.
UPDATE schema_version
SET version = '6', minor = '0';
$$
DELIMITER ;
-# Update the schema version number
+# Update the schema version number.
UPDATE schema_version
SET version = '7', minor = '0';
END $$
DELIMITER ;
-# Update the schema version number
+# Update the schema version number.
UPDATE schema_version
SET version = '8', minor = '0';
ALTER TABLE hosts
MODIFY COLUMN auth_key VARCHAR(32) NULL;
-# Update the schema version number
+# Update the schema version number.
UPDATE schema_version
SET version = '8', minor = '1';
END $$
DELIMITER ;
-# Update the schema version number
+# Update the schema version number.
UPDATE schema_version
SET version = '8', minor = '2';
# Create hostname index for lease6
CREATE INDEX lease6_by_hostname ON lease6 (hostname);
-# Update the schema version number
+# Update the schema version number.
UPDATE schema_version
SET version = '9', minor = '0';
ADD COLUMN ddns_generated_prefix VARCHAR(255) DEFAULT NULL,
ADD COLUMN ddns_qualifying_suffix VARCHAR(255) DEFAULT NULL;
-# Update the schema version number
+# Update the schema version number.
UPDATE schema_version
SET version = '9', minor = '1';
REFERENCES dhcp6_pd_pool(id)
ON DELETE CASCADE ON UPDATE CASCADE;
-# Update the schema version number
+# Update the schema version number.
UPDATE schema_version
SET version = '9', minor = '2';
END $$
DELIMITER ;
-# Update the schema version number
+# Update the schema version number.
UPDATE schema_version
SET version = '9', minor = '3';
REFERENCES hosts(host_id)
ON DELETE CASCADE ON UPDATE CASCADE;
-# Update the schema version number
+# Update the schema version number.
UPDATE schema_version
SET version = '9', minor = '4';
ALTER TABLE dhcp6_subnet DROP COLUMN reservation_mode;
ALTER TABLE dhcp6_shared_network DROP COLUMN reservation_mode;
-# Update the schema version number
+# Update the schema version number.
UPDATE schema_version
SET version = '9', minor = '5';
ALTER TABLE logs
ADD id INT UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY;
-# Update the schema version number
+# Update the schema version number.
UPDATE schema_version
SET version = '9', minor = '6';
# This line concludes the schema upgrade to version 9.6.
-# This line starts the schema upgrade to version 10.
+# This line starts the schema upgrade to version 10.0.
-- -----------------------------------------------------------------------
-- Create a table holding the DHCPv4 client classes. Most table
ON DELETE CASCADE
ON UPDATE CASCADE;
-# Update the schema version number
+# Update the schema version number.
UPDATE schema_version
SET version = '10', minor = '0';
-# This line concludes the schema upgrade to version 10.
+# This line concludes the schema upgrade to version 10.0.
-# This line starts the schema upgrade to version 11.
+# This line starts the schema upgrade to version 11.0.
# Reverse index order to improve reclamation query performance
# Add a constraint that any state value added to the lease4 must
ADD COLUMN min_preferred_lifetime INT(10) DEFAULT NULL,
ADD COLUMN max_preferred_lifetime INT(10) DEFAULT NULL;
-# Update the schema version number
+# Update the schema version number.
UPDATE schema_version
SET version = '11', minor = '0';
-# This line concludes the schema upgrade to version 11.
+# This line concludes the schema upgrade to version 11.0.
-# This line starts the schema upgrade to version 12.
+# This line starts the schema upgrade to version 12.0.
# Ensure that dhcp_client_class is NULL when an option does not
# belong to any client class. Later, we will add foreign keys for
REFERENCES dhcp6_client_class (name)
ON DELETE CASCADE ON UPDATE CASCADE;
-# Update the schema version number
+# Update the schema version number.
UPDATE schema_version
SET version = '12', minor = '0';
--- This line concludes the schema upgrade to version 12.
+-- This line concludes the schema upgrade to version 12.0.
--- This line starts the schema upgrade to version 13.
+-- This line starts the schema upgrade to version 13.0.
-- Create a function that separates a contiguous hexadecimal string
-- into groups of two hexadecimals separated by colons.
UPDATE schema_version
SET version = '13', minor = '0';
--- This line concludes the schema upgrade to version 13.
+-- This line concludes the schema upgrade to version 13.0.
--- This line starts the schema upgrade to version 14.
+-- This line starts the schema upgrade to version 14.0.
-- Modify shared-network-name foreign key constraint on dhcp4_subnet to not perform
-- the update when the network is deleted the cascaded update will not execute
UPDATE schema_version
SET version = '14', minor = '0';
--- This line concludes the schema upgrade to version 14.
+-- This line concludes the schema upgrade to version 14.0.
--- This line starts the schema upgrade to version 15.
+-- This line starts the schema upgrade to version 15.0.
-- Add cancelled (aka never-send) column to option tables.
ALTER TABLE dhcp4_options
UPDATE schema_version
SET version = '15', minor = '0';
--- This line concludes the schema upgrade to version 15.
+-- This line concludes the schema upgrade to version 15.0.
--- This line starts the schema upgrade to version 16.
+-- This line starts the schema upgrade to version 16.0.
-- Add relay and remote id columns to DHCPv4 leases.
--
UPDATE schema_version
SET version = '16', minor = '0';
--- This line concludes the schema upgrade to version 16.
+-- This line concludes the schema upgrade to version 16.0.
--- This line starts the schema upgrade to version 17.
+-- This line starts the schema upgrade to version 17.0.
-- Add the allocator column to the DHCPv4 tables.
ALTER TABLE dhcp4_subnet ADD COLUMN allocator TEXT NULL;
UPDATE schema_version
SET version = '17', minor = '0';
--- This line concludes the schema upgrade to version 17.
+-- This line concludes the schema upgrade to version 17.0.
--- This line starts the schema upgrade to version 18.
+-- This line starts the schema upgrade to version 18.0.
-- Extend lease4 client_id to 255 bytes.
ALTER TABLE lease4
UPDATE schema_version
SET version = '18', minor = '0';
--- This line concludes the schema upgrade to version 18.
+-- This line concludes the schema upgrade to version 18.0.
# Notes:
#
fi
mysql "$@" <<EOF
+-- This line starts the schema upgrade to version 2.0.
+
ALTER TABLE lease6
ADD COLUMN hwaddr varbinary(20),
ADD COLUMN hwtype smallint unsigned,
INSERT INTO lease_hwaddr_source VALUES (32, 'HWADDR_SOURCE_SUBSCRIBER_ID');
INSERT INTO lease_hwaddr_source VALUES (64, 'HWADDR_SOURCE_DOCSIS');
-# Update the schema version number
+# Update the schema version number.
UPDATE schema_version
SET version = '2', minor = '0';
fi
mysql "$@" <<EOF
+-- This line starts the schema upgrade to version 3.0.
+
CREATE TABLE IF NOT EXISTS hosts (
host_id INT UNSIGNED NOT NULL AUTO_INCREMENT ,
dhcp_identifier VARBINARY(128) NOT NULL ,
$$
DELIMITER ;
-# Update the schema version number
+# Update the schema version number.
UPDATE schema_version
SET version = '3', minor = '0';
fi
mysql "$@" <<EOF
+-- This line starts the schema upgrade to version 4.0.
+
# Add state column to the lease4 table.
ALTER TABLE lease4
ADD COLUMN state INT UNSIGNED DEFAULT 0;
END $$
DELIMITER ;
-# Update the schema version number
+# Update the schema version number.
UPDATE schema_version
SET version = '4', minor = '0';
fi
mysql "$@" <<EOF
+-- This line starts the schema upgrade to version 4.1.
# In the event hardware address cannot be determined, we need to satisfy
# foreign key constraint between lease6 and lease_hardware_source
END $$
DELIMITER ;
-# Update the schema version number
+# Update the schema version number.
UPDATE schema_version
SET version = '4', minor = '1';
fi
mysql "$@" <<EOF
+-- This line starts the schema upgrade to version 5.0.
# Update index used for searching DHCPv4 reservations by identifier and subnet id.
# This index is now unique (to prevent duplicates) and includes DHCPv4 subnet
ALTER TABLE hosts ADD COLUMN dhcp4_server_hostname VARCHAR(64) NULL;
ALTER TABLE hosts ADD COLUMN dhcp4_boot_file_name VARCHAR(128) NULL;
-# Update the schema version number
+# Update the schema version number.
UPDATE schema_version
SET version = '5', minor = '0';
fi
mysql "$@" <<EOF
+-- This line starts the schema upgrade to version 5.1.
# Add missing 'client-id' and new 'flex-id' host identifier types.
INSERT INTO host_identifier_type VALUES (3, 'client-id');
$$
DELIMITER ;
-# Update the schema version number
+# Update the schema version number.
UPDATE schema_version
SET version = '5', minor = '1';
fi
mysql "$@" <<EOF
+-- This line starts the schema upgrade to version 5.2.
# Make subnet_id column types consistent with lease table columns
ALTER TABLE dhcp4_options MODIFY dhcp4_subnet_id INT UNSIGNED;
ALTER TABLE dhcp6_options MODIFY dhcp6_subnet_id INT UNSIGNED;
-# Update the schema version number
+# Update the schema version number.
UPDATE schema_version
SET version = '5', minor = '2';
fi
mysql "$@" <<EOF
+-- This line starts the schema upgrade to version 6.0.
# Add user context into table holding hosts
ALTER TABLE hosts ADD COLUMN user_context TEXT NULL;
GROUP BY subnet_id, lease_type, state
ORDER BY subnet_id;
-# Update the schema version number
+# Update the schema version number.
UPDATE schema_version
SET version = '6', minor = '0';
fi
mysql "$@" <<EOF
+-- This line starts the schema upgrade to version 7.0.
# Add user context into tables holding leases
ALTER TABLE lease4 ADD COLUMN user_context TEXT NULL;
$$
DELIMITER ;
-# Update the schema version number
+# Update the schema version number.
UPDATE schema_version
SET version = '7', minor = '0';
fi
mysql "$@" <<EOF
+-- This line starts the schema upgrade to version 8.0.
ALTER TABLE dhcp4_options
MODIFY COLUMN modification_ts TIMESTAMP NOT NULL
END $$
DELIMITER ;
-# Update the schema version number
+# Update the schema version number.
UPDATE schema_version
SET version = '8', minor = '0';
fi
mysql "$@" <<EOF
+-- This line starts the schema upgrade to version 8.1.
# Add lifetime bounds
ALTER TABLE dhcp4_shared_network
ALTER TABLE hosts
MODIFY COLUMN auth_key VARCHAR(32) NULL;
-# Update the schema version number
+# Update the schema version number.
UPDATE schema_version
SET version = '8', minor = '1';
}
mysql "$@" <<EOF
+-- This line starts the schema upgrade to version 8.2.
# Drop existing trigger on the dhcp4_shared_network table.
DROP TRIGGER dhcp4_shared_network_ADEL;
END $$
DELIMITER ;
-# Update the schema version number
+# Update the schema version number.
UPDATE schema_version
SET version = '8', minor = '2';
fi
mysql "$@" <<EOF
+-- This line starts the schema upgrade to version 9.0.
# Create hostname index for host reservations
CREATE INDEX hosts_by_hostname ON hosts (hostname);
# Create hostname index for lease6
CREATE INDEX lease6_by_hostname ON lease6 (hostname);
-# Update the schema version number
+# Update the schema version number.
UPDATE schema_version
SET version = '9', minor = '0';
fi
mysql "$@" <<EOF
+-- This line starts the schema upgrade to version 9.1.
# Add new DDNS related columns to shared networks and subnets
ALTER TABLE dhcp4_shared_network
ADD COLUMN ddns_generated_prefix VARCHAR(255) DEFAULT NULL,
ADD COLUMN ddns_qualifying_suffix VARCHAR(255) DEFAULT NULL;
-# Update the schema version number
+# Update the schema version number.
UPDATE schema_version
SET version = '9', minor = '1';
fi
mysql "$@" <<EOF
+-- This line starts the schema upgrade to version 9.2.
# Add missing indexes (foreign keys) to the dhcp4_options table.
ALTER TABLE dhcp4_options ADD CONSTRAINT fk_dhcp4_options_shared_network
REFERENCES dhcp6_pd_pool(id)
ON DELETE CASCADE ON UPDATE CASCADE;
-# Update the schema version number
+# Update the schema version number.
UPDATE schema_version
SET version = '9', minor = '2';
fi
mysql "$@" <<EOF
+-- This line starts the schema upgrade to version 9.3.
# Fix stat_lease4_update trigger
DROP TRIGGER stat_lease4_update;
END $$
DELIMITER ;
-# Update the schema version number
+# Update the schema version number.
UPDATE schema_version
SET version = '9', minor = '3';
fi
mysql "$@" <<EOF
+-- This line starts the schema upgrade to version 9.4.
# Starting from this version we allow specifying multiple IP reservations
# for the same address in certain DHCP configurations. The server may check
REFERENCES hosts(host_id)
ON DELETE CASCADE ON UPDATE CASCADE;
-# Update the schema version number
+# Update the schema version number.
UPDATE schema_version
SET version = '9', minor = '4';
fi
mysql "$@" <<EOF
+-- This line starts the schema upgrade to version 9.5.
# Add new reservations flags.
ALTER TABLE dhcp4_subnet
# Enable audit in this session
SET @disable_audit = 0;
-# Update the schema version number
+# Update the schema version number.
UPDATE schema_version
SET version = '9', minor = '5';
fi
mysql "${@}" <<EOF
+-- This line starts the schema upgrade to version 9.6.
+
# Add an auto-increment ID as primary key to support Percona.
ALTER TABLE logs
ADD id INT UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY;
-# Update the schema version number
+# Update the schema version number.
UPDATE schema_version
SET version = '9', minor = '6';
shrink_tag_column "${schema}" dhcp6_server "${@}"
mysql "$@" <<EOF
+-- This line starts the schema upgrade to version 10.0.
-- -----------------------------------------------------------------------
-- Create a table holding the DHCPv4 client classes. Most table
ON DELETE CASCADE
ON UPDATE CASCADE;
-# Update the schema version number
+# Update the schema version number.
UPDATE schema_version
SET version = '10', minor = '0';
-# This line concludes the schema upgrade to version 10.
+# This line concludes the schema upgrade to version 10.0.
EOF
fi
mysql "$@" <<EOF
+-- This line starts the schema upgrade to version 11.0.
-- Reverse index order to improve reclamation query performance
-- Add a constraint that any state value added to the lease4 must
ADD COLUMN min_preferred_lifetime INT(10) DEFAULT NULL,
ADD COLUMN max_preferred_lifetime INT(10) DEFAULT NULL;
--- Update the schema version number
+-- Update the schema version number.
UPDATE schema_version
SET version = '11', minor = '0';
fi
mysql "$@" <<EOF
+-- This line starts the schema upgrade to version 12.0.
-- Ensure that dhcp_client_class is NULL when an option does not
-- belong to any client class. Later, we will add foreign keys for
REFERENCES dhcp6_client_class (name)
ON DELETE CASCADE ON UPDATE CASCADE;
--- Update the schema version number
+-- Update the schema version number.
UPDATE schema_version
SET version = '12', minor = '0';
--- This line concludes the schema upgrade to version 12.
+-- This line concludes the schema upgrade to version 12.0.
EOF
fi
mysql "$@" <<EOF
+-- This line starts the schema upgrade to version 13.0.
-- Create a function that separates a contiguous hexadecimal string
-- into groups of two hexadecimals separated by colons.
UPDATE schema_version
SET version = '13', minor = '0';
--- This line concludes the schema upgrade to version 13.
+-- This line concludes the schema upgrade to version 13.0.
EOF
fi
mysql "$@" <<EOF
+-- This line starts the schema upgrade to version 14.0.
-- Modify shared-network-name foreign key constraint on dhcp4_subnet to not perform
-- the update when the network is deleted the cascaded update will not execute
UPDATE schema_version
SET version = '14', minor = '0';
--- This line concludes the schema upgrade to version 14.
+-- This line concludes the schema upgrade to version 14.0.
EOF
fi
mysql "$@" <<EOF
--- This line starts the schema upgrade to version 15.
+-- This line starts the schema upgrade to version 15.0.
-- Add cancelled (aka never-send) column to option tables.
ALTER TABLE dhcp4_options
UPDATE schema_version
SET version = '15', minor = '0';
--- This line concludes the schema upgrade to version 15.
+-- This line concludes the schema upgrade to version 15.0.
EOF
fi
mysql "$@" <<EOF
--- This line starts the schema upgrade to version 16.
+-- This line starts the schema upgrade to version 16.0.
-- Add relay and remote id columns to DHCPv4 leases.
--
UPDATE schema_version
SET version = '16', minor = '0';
--- This line concludes the schema upgrade to version 16.
+-- This line concludes the schema upgrade to version 16.0.
EOF
fi
mysql "$@" <<EOF
--- This line starts the schema upgrade to version 17.
+-- This line starts the schema upgrade to version 17.0.
-- Add the allocator column to the DHCPv4 tables.
ALTER TABLE dhcp4_subnet ADD COLUMN allocator TEXT NULL;
UPDATE schema_version
SET version = '17', minor = '0';
--- This line concludes the schema upgrade to version 17.
+-- This line concludes the schema upgrade to version 17.0.
EOF
fi
mysql "$@" <<EOF
--- This line starts the schema upgrade to version 18.
+-- This line starts the schema upgrade to version 18.0.
-- Extend lease4 client_id to 255 bytes.
ALTER TABLE lease4
UPDATE schema_version
SET version = '18', minor = '0';
--- This line concludes the schema upgrade to version 18.
+-- This line concludes the schema upgrade to version 18.0.
EOF
INSERT INTO schema_version VALUES (1, 0);
--- Upgrade to schema 2.0 begins here:
+-- This line starts the schema upgrade to version 2.0.
-- Add state column to the lease4 table.
ALTER TABLE lease4
$$ LANGUAGE SQL;
--
--- Set 2.0 schema version.
+-- Update the schema version number.
UPDATE schema_version
SET version = '2', minor = '0';
--- Schema 2.0 specification ends here.
+-- This line concludes the schema upgrade to version 2.0.
--- Upgrade to schema 3.0 begins here:
+-- This line starts the schema upgrade to version 3.0.
--
-- Table structure for table host_identifier_type.
ALTER TABLE hosts ADD COLUMN dhcp4_server_hostname VARCHAR(64) DEFAULT NULL;
ALTER TABLE hosts ADD COLUMN dhcp4_boot_file_name VARCHAR(128) DEFAULT NULL;
--- Set 3.0 schema version.
+-- Update the schema version number.
UPDATE schema_version
SET version = '3', minor = '0';
--- Schema 3.0 specification ends here.
+-- This line concludes the schema upgrade to version 3.0.
--- Upgrade to schema 3.1 begins here:
+-- This line starts the schema upgrade to version 3.1.
-- This is a placeholder for the changes between 3.0 and 3.1. We have added a
-- missing 'client-id' host reservation type entry that had been accidentally
-- Also, new flexible identifier has been added.
INSERT INTO host_identifier_type VALUES (4, 'flex-id');
--- Set 3.1 schema version.
+-- Update the schema version number.
UPDATE schema_version
SET version = '3', minor = '1';
--- Schema 3.1 specification ends here.
+-- This line concludes the schema upgrade to version 3.1.
--- Upgrade to schema 3.2 begins here:
+-- This line starts the schema upgrade to version 3.2.
-- Remove constraints which perform too restrictive checks on the inserted
-- host reservations. We want to be able to insert host reservations which
(dhcp_identifier ASC, dhcp_identifier_type ASC, dhcp6_subnet_id ASC)
WHERE (dhcp6_subnet_id IS NOT NULL AND dhcp6_subnet_id <> 0);
--- Set 3.2 schema version.
+-- Update the schema version number.
UPDATE schema_version
SET version = '3', minor = '2';
--- Schema 3.2 specification ends here.
+-- This line concludes the schema upgrade to version 3.2.
--- Upgrade to schema 3.3 begins here:
+-- This line starts the schema upgrade to version 3.3.
-- Change subnet ID columns type to BIGINT to match lease4/6 tables
ALTER TABLE hosts ALTER COLUMN dhcp4_subnet_id TYPE BIGINT;
ALTER TABLE dhcp4_options ALTER COLUMN dhcp4_subnet_id TYPE BIGINT;
ALTER TABLE dhcp6_options ALTER COLUMN dhcp6_subnet_id TYPE BIGINT;
--- Set 3.3 schema version.
+-- Update the schema version number.
UPDATE schema_version
SET version = '3', minor = '3';
--- Schema 3.3 specification ends here.
+-- This line concludes the schema upgrade to version 3.3.
--- Upgrade to schema 4.0 begins here:
+-- This line starts the schema upgrade to version 4.0.
-- Add a column holding hosts for user context.
ALTER TABLE hosts ADD COLUMN user_context TEXT;
AFTER DELETE ON lease6
FOR EACH ROW EXECUTE PROCEDURE proc_stat_lease6_delete();
--- Set 4.0 schema version.
+-- Update the schema version number.
UPDATE schema_version
SET version = '4', minor = '0';
--- Schema 4.0 specification ends here.
+-- This line concludes the schema upgrade to version 4.0.
--- Upgrade to schema 5.0 begins here:
+-- This line starts the schema upgrade to version 5.0.
-- Add a column holding leases for user context.
ALTER TABLE lease4 ADD COLUMN user_context TEXT;
-- Create auth_key in hosts table for storing keys for DHCPv6 reconfigure.
ALTER TABLE hosts ADD COLUMN auth_key VARCHAR(16) DEFAULT NULL;
--- Set schema 5.0 version.
+-- Update the schema version number.
UPDATE schema_version
SET version = '5', minor = '0';
--- Schema 5.0 specification ends here.
+-- This line concludes the schema upgrade to version 5.0.
--- Upgrade to schema 5.1 begins here:
+-- This line starts the schema upgrade to version 5.1.
-- Put the auth key in hexadecimal (double size but far more user friendly).
ALTER TABLE hosts ALTER COLUMN auth_key TYPE VARCHAR(32);
--- Set schema 5.1 version.
+-- Update the schema version number.
UPDATE schema_version
SET version = '5', minor = '1';
--- Schema 5.1 specification ends here.
+-- This line concludes the schema upgrade to version 5.1.
--- Upgrade to schema 6.0 begins here:
+-- This line starts the schema upgrade to version 6.0.
-- Create a lower case hostname index for hosts.
CREATE INDEX hosts_by_hostname ON hosts (lower(hostname))
CREATE INDEX lease6_by_hostname ON lease6 (lower(hostname))
WHERE hostname IS NOT NULL;
--- Set 6.0 schema version.
+-- Update the schema version number.
UPDATE schema_version
SET version = '6', minor = '0';
--- Schema 6.0 specification ends here.
+-- This line concludes the schema upgrade to version 6.0.
--- Upgrade to schema 6.1 begins here:
+-- This line starts the schema upgrade to version 6.1.
-- Fix v4 update trigger procedure
CREATE OR REPLACE FUNCTION proc_stat_lease4_update() RETURNS trigger AS $stat_lease4_update$
END;
$stat_lease6_delete$ LANGUAGE plpgsql;
--- Set 6.1 schema version.
+-- Update the schema version number.
UPDATE schema_version
SET version = '6', minor = '1';
--- Schema 6.1 specification ends here.
+-- This line concludes the schema upgrade to version 6.1.
--- Upgrade to schema 6.2 begins here:
+-- This line starts the schema upgrade to version 6.2.
-- Starting from this version we allow specifying multiple IP reservations
-- for the same address in certain DHCP configurations. The server may check
CREATE INDEX key_dhcp6_address_prefix_len
ON ipv6_reservations (address ASC, prefix_len ASC);
--- Set schema 6.2 version.
+-- Update the schema version number.
UPDATE schema_version
SET version = '6', minor = '2';
--- Schema 6.2 specification ends here.
+-- This line concludes the schema upgrade to version 6.2.
--- Upgrade to schema 7.0 begins here:
+-- This line starts the schema upgrade to version 7.0.
-- Add a lot (20+) of tables for the config backend.
$dhcp6_pd_pool_BDEL$
LANGUAGE plpgsql;
--- Set schema 7.0 version.
+-- Update the schema version number.
UPDATE schema_version
SET version = '7', minor = '0';
--- Schema 7.0 specification ends here.
+-- This line concludes the schema upgrade to version 7.0.
--- Upgrade to schema 8.0 begins here:
+-- This line starts the schema upgrade to version 8.0.
-- Add a few missing elements for CB and functions for kea-admin's lease-dump
-- and lease-upload commands.
END
$$ LANGUAGE plpgsql;
--- Set schema 8.0 version.
+-- Update the schema version number.
UPDATE schema_version
SET version = '8', minor = '0';
--- Schema 8.0 specification ends here.
+-- This line concludes the schema upgrade to version 8.0.
--- Upgrade to schema 9.0 begins here:
+-- This line starts the schema upgrade to version 9.0.
-- Add missing cascade to constraint on dhcp4/6_subnet_server tables.
ALTER TABLE dhcp4_subnet_server
END;$$
LANGUAGE plpgsql;
--- Set schema 9.0 version.
+-- Update the schema version number.
UPDATE schema_version
SET version = '9', minor = '0';
--- Schema 9.0 specification ends here.
+-- This line concludes the schema upgrade to version 9.0.
--- Upgrade to schema 10.0 begins here:
+-- This line starts the schema upgrade to version 10.0.
-- It adds corrections for client classes for CB
$dhcp6_client_class_check_dependency_BINS$
LANGUAGE plpgsql;
--- Set schema 10.0 version.
+-- Update the schema version number.
UPDATE schema_version
SET version = '10', minor = '0';
--- Schema 10.0 specification ends here.
+-- This line concludes the schema upgrade to version 10.0.
--- Upgrade to schema 11.0 begins here:
+-- This line starts the schema upgrade to version 11.0.
-- Replace createOptionAuditDHCP6() with a version corrected
-- where clause when scope is 6 (i.e. PD pool)
RETURN;
END;$$;
--- Set schema 11.0 version.
+-- Update the schema version number.
UPDATE schema_version
SET version = '11', minor = '0';
--- Schema 11.0 specification ends here.
+-- This line concludes the schema upgrade to version 11.0.
--- Upgrade to schema 12.0 begins here:
+-- This line starts the schema upgrade to version 12.0.
-- Modify shared-network-name foreign key constraint on dhcp4_subnet to not perform
-- the update when the network is deleted the cascaded update will not execute
ALTER TABLE dhcp4_client_class ADD COLUMN user_context JSON DEFAULT NULL;
ALTER TABLE dhcp6_client_class ADD COLUMN user_context JSON DEFAULT NULL;
--- Set schema 12.0 version.
+-- Update the schema version number.
UPDATE schema_version
SET version = '12', minor = '0';
--- Schema 12.0 specification ends here.
+-- This line concludes the schema upgrade to version 12.0.
--- Upgrade to schema 13.0 begins here:
+-- This line starts the schema upgrade to version 13.0.
-- JSON functions --
(dhcp_identifier ASC, dhcp_identifier_type ASC, dhcp6_subnet_id ASC)
WHERE (dhcp6_subnet_id IS NOT NULL);
--- Set schema 13.0 version.
+-- Update the schema version number.
UPDATE schema_version
SET version = '13', minor = '0';
--- Schema 13.0 specification ends here.
+-- This line concludes the schema upgrade to version 13.0.
--- Upgrade to schema 14.0 begins here:
+-- This line starts the schema upgrade to version 14.0.
-- Add cancelled (aka never-send) column to option tables.
ALTER TABLE dhcp4_client_class
ADD COLUMN offer_lifetime BIGINT DEFAULT NULL;
--- Set schema 14.0 version.
+-- Update the schema version number.
UPDATE schema_version
SET version = '14', minor = '0';
--- Schema 14.0 specification ends here.
+-- This line concludes the schema upgrade to version 14.0.
--- Upgrade to schema 15.0 begins here:
+-- This line starts the schema upgrade to version 15.0.
-- Add relay and remote id columns to DHCPv4 leases.
--
CREATE INDEX lease4_by_relay_id ON lease4 (relay_id);
CREATE INDEX lease4_by_remote_id ON lease4 (remote_id);
--- Set schema 15.0 version.
+-- Update the schema version number.
UPDATE schema_version
SET version = '15', minor = '0';
--- Schema 15.0 specification ends here.
+-- This line concludes the schema upgrade to version 15.0.
--- Upgrade to schema 16.0 begins here:
-
-UPDATE lease6 SET duid = E'\\x000000' WHERE duid = E'\\x00';
-
--- Set 16.0 schema version.
-UPDATE schema_version
- SET version = '16', minor = '0';
-
--- Schema 16.0 specification ends here.
-
--- Upgrade to schema 16.0 begins here:
+-- This line starts the schema upgrade to version 16.0.
-- Add the allocator column to the DHCPv4 tables.
ALTER TABLE dhcp4_subnet ADD COLUMN allocator TEXT DEFAULT NULL;
ALTER TABLE dhcp6_shared_network ADD COLUMN allocator TEXT DEFAULT NULL;
ALTER TABLE dhcp6_shared_network ADD COLUMN pd_allocator TEXT DEFAULT NULL;
--- Set 17.0 schema version.
+-- Update the schema version number.
+UPDATE schema_version
+ SET version = '16', minor = '0';
+
+-- This line concludes the schema upgrade to version 16.0.
+
+-- This line starts the schema upgrade to version 17.0.
+
+UPDATE lease6 SET duid = E'\\x000000' WHERE duid = E'\\x00';
+
+-- Update the schema version number.
UPDATE schema_version
SET version = '17', minor = '0';
--- Schema 17.0 specification ends here.
+-- This line concludes the schema upgrade to version 17.0.
-- Commit the script transaction.
COMMIT;
psql "$@" >/dev/null <<EOF
--- Upgrade to schema 2.0 begins here:
+-- This line starts the schema upgrade to version 2.0.
-- Add state column to the lease4 table.
ALTER TABLE lease4
\$\$ LANGUAGE SQL;
--
--- Set 2.0 schema version.
+-- Update the schema version number.
START TRANSACTION;
UPDATE schema_version
SET version = '2', minor = '0';
--- Schema 2.0 specification ends here.
+-- This line concludes the schema upgrade to version 2.0.
--- Commit the script transaction
+-- Commit the script transaction.
COMMIT;
EOF
START TRANSACTION;
--- Upgrade to schema 3.0 begins here:
+-- This line starts the schema upgrade to version 3.0.
--
-- Table structure for table host_identifier_type
ALTER TABLE hosts ADD COLUMN dhcp4_server_hostname VARCHAR(64) DEFAULT NULL;
ALTER TABLE hosts ADD COLUMN dhcp4_boot_file_name VARCHAR(128) DEFAULT NULL;
--- Set 3.0 schema version.
+-- Update the schema version number.
UPDATE schema_version
SET version = '3', minor = '0';
--- Schema 3.0 specification ends here.
+-- This line concludes the schema upgrade to version 3.0.
--- Commit the script transaction
+-- Commit the script transaction.
COMMIT;
EOF
START TRANSACTION;
--- Upgrade to schema 3.1 begins here:
+-- This line starts the schema upgrade to version 3.1.
-- The 'client-id' host identifier type was missing in the
-- 2.0 -> 3.0 upgrade script. However, it was present in the
-- We also add a new identifier type: flex-id.
INSERT INTO host_identifier_type VALUES (4, 'flex-id');
--- Set 3.1 schema version.
+-- Update the schema version number.
UPDATE schema_version
SET version = '3', minor = '1';
--- Schema 3.1 specification ends here.
+-- This line concludes the schema upgrade to version 3.1.
--- Commit the script transaction
+-- Commit the script transaction.
COMMIT;
EOF
START TRANSACTION;
--- Upgrade to schema 3.2 begins here:
+-- This line starts the schema upgrade to version 3.2.
-- Remove constraints which perform too restrictive checks on the inserted
-- host reservations. We want to be able to insert host reservations which
(dhcp_identifier ASC, dhcp_identifier_type ASC, dhcp6_subnet_id ASC)
WHERE (dhcp6_subnet_id IS NOT NULL AND dhcp6_subnet_id <> 0);
--- Set 3.2 schema version.
+-- Update the schema version number.
UPDATE schema_version
SET version = '3', minor = '2';
--- Schema 3.2 specification ends here.
+-- This line concludes the schema upgrade to version 3.2.
--- Commit the script transaction
+-- Commit the script transaction.
COMMIT;
EOF
START TRANSACTION;
--- Upgrade to schema 3.3 begins here:
+-- This line starts the schema upgrade to version 3.3.
-- Change subnet ID columns type to BIGINT to match lease4/6 tables
ALTER TABLE hosts ALTER COLUMN dhcp4_subnet_id TYPE BIGINT;
ALTER TABLE dhcp4_options ALTER COLUMN dhcp4_subnet_id TYPE BIGINT;
ALTER TABLE dhcp6_options ALTER COLUMN dhcp6_subnet_id TYPE BIGINT;
--- Set 3.3 schema version.
+-- Update the schema version number.
UPDATE schema_version
SET version = '3', minor = '3';
--- Schema 3.3 specification ends here.
+-- This line concludes the schema upgrade to version 3.3.
--- Commit the script transaction
+-- Commit the script transaction.
COMMIT;
EOF
START TRANSACTION;
--- Upgrade to schema 4.0 begins here:
+-- This line starts the schema upgrade to version 4.0.
-- Add a column holding hosts for user context.
ALTER TABLE hosts ADD COLUMN user_context TEXT;
GROUP BY subnet_id, lease_type, state
ORDER BY subnet_id;
--- Set 4.0 schema version.
+-- Update the schema version number.
UPDATE schema_version
SET version = '4', minor = '0';
--- Schema 4.0 specification ends here.
+-- This line concludes the schema upgrade to version 4.0.
--- Commit the script transaction
+-- Commit the script transaction.
COMMIT;
EOF
START TRANSACTION;
--- Upgrade to schema 5.0 begins here:
+-- This line starts the schema upgrade to version 5.0.
-- Add a column holding leases for user context.
ALTER TABLE lease4 ADD COLUMN user_context TEXT;
UPDATE hosts SET dhcp6_subnet_id = NULL WHERE dhcp6_subnet_id = 0;
UPDATE dhcp6_options SET dhcp6_subnet_id = NULL WHERE dhcp6_subnet_id = 0;
--- Set 5.0 schema version.
+-- Update the schema version number.
UPDATE schema_version
SET version = '5', minor = '0';
--- Schema 5.0 specification ends here.
+-- This line concludes the schema upgrade to version 5.0.
--- Commit the script transaction
+-- Commit the script transaction.
COMMIT;
EOF
START TRANSACTION;
--- Upgrade to schema 5.1 begins here:
+-- This line starts the schema upgrade to version 5.1.
-- Put the auth key in hexadecimal (double size but far more user friendly).
ALTER TABLE hosts ALTER COLUMN auth_key TYPE VARCHAR(32);
--- Set 5.1 schema version.
+-- Update the schema version number.
UPDATE schema_version
SET version = '5', minor = '1';
--- Schema 5.1 specification ends here.
+-- This line concludes the schema upgrade to version 5.1.
--- Commit the script transaction
+-- Commit the script transaction.
COMMIT;
EOF
START TRANSACTION;
--- Upgrade to schema 6.0 begins here:
+-- This line starts the schema upgrade to version 6.0.
-- Create a lower case hostname index for hosts.
CREATE INDEX hosts_by_hostname ON hosts (lower(hostname))
-- UPDATE lease6 SET hostname = lower(hostname)
-- WHERE lower(hostname) != hostname;
--- Set 6.0 schema version.
+-- Update the schema version number.
UPDATE schema_version
SET version = '6', minor = '0';
--- Schema 6.0 specification ends here.
+-- This line concludes the schema upgrade to version 6.0.
--- Commit the script transaction
+-- Commit the script transaction.
COMMIT;
EOF
START TRANSACTION;
--- Upgrade to schema 6.1 begins here:
+-- This line starts the schema upgrade to version 6.1.
-- Fix v4 update trigger procedure
CREATE OR REPLACE FUNCTION proc_stat_lease4_update () RETURNS trigger AS \$stat_lease4_update\$
END;
\$stat_lease6_delete\$ LANGUAGE plpgsql;
--- Set 6.1 schema version.
+-- Update the schema version number.
UPDATE schema_version
SET version = '6', minor = '1';
--- Schema 6.1 specification ends here.
+-- This line concludes the schema upgrade to version 6.1.
--- Commit the script transaction
+-- Commit the script transaction.
COMMIT;
EOF
psql "$@" >/dev/null <<EOF
--- Upgrade to schema 6.2 begins here:
+-- This line starts the schema upgrade to version 6.2.
-- Starting from this version we allow specifying multiple IP reservations
-- for the same address in certain DHCP configurations. The server may check
CREATE INDEX key_dhcp6_address_prefix_len
ON ipv6_reservations (address ASC, prefix_len ASC);
--- Set 6.2 schema version.
+-- Update the schema version number.
UPDATE schema_version
SET version = '6', minor = '2';
--- Schema 6.2 specification ends here.
+-- This line concludes the schema upgrade to version 6.2.
--- Commit the script transaction
+-- Commit the script transaction.
COMMIT;
EOF
START TRANSACTION;
--- Upgrade to schema 7.0 begins here:
+-- This line starts the schema upgrade to version 7.0.
-- Add a lot (20+) of tables for the config backend.
\$dhcp6_pd_pool_BDEL\$
LANGUAGE plpgsql;
--- Set 7.0 schema version.
+-- Update the schema version number.
UPDATE schema_version
SET version = '7', minor = '0';
--- Schema 7.0 specification ends here.
+-- This line concludes the schema upgrade to version 7.0.
--- Commit the script transaction
+-- Commit the script transaction.
COMMIT;
EOF
psql "$@" >/dev/null <<EOF
START TRANSACTION;
--- Upgrade to schema 8.0 begins here:
+-- This line starts the schema upgrade to version 8.0.
-- Adds a few missing elements for CB and functions for kea-admin's lease-dump
-- and lease-upload commands.
END
\$\$ LANGUAGE plpgsql;
--- Set 8.0 schema version.
+-- Update the schema version number.
UPDATE schema_version
SET version = '8', minor = '0';
+-- This line concludes the schema upgrade to version 8.0.
+
-- Commit the script transaction.
COMMIT;
psql "$@" >/dev/null <<EOF
START TRANSACTION;
--- Upgrade to schema 9.0 begins here:
+-- This line starts the schema upgrade to version 9.0.
-- Add missing cascade to constraint on dhcp4/6_subnet_server tables.
ALTER TABLE dhcp4_subnet_server
END;\$\$
LANGUAGE plpgsql;
--- Set 9.0 schema version.
+-- Update the schema version number.
UPDATE schema_version
SET version = '9', minor = '0';
--- Schema 9.0 specification ends here.
+-- This line concludes the schema upgrade to version 9.0.
-- Commit the script transaction.
COMMIT;
psql "$@" >/dev/null <<EOF
START TRANSACTION;
--- Upgrade to schema 10.0 begins here:
+-- This line starts the schema upgrade to version 10.0.
-- It adds corrections for client classes for CB
\$dhcp6_client_class_check_dependency_BINS\$
LANGUAGE plpgsql;
--- Set 10.0 schema version.
+-- Update the schema version number.
UPDATE schema_version
SET version = '10', minor = '0';
--- Schema 10.0 specification ends here.
+-- This line concludes the schema upgrade to version 10.0.
-- Commit the script transaction.
COMMIT;
psql "$@" >/dev/null <<EOF
START TRANSACTION;
--- Upgrade to schema 11.0 begins here:
+-- This line starts the schema upgrade to version 11.0.
-- Replace createOptionAuditDHCP6() with a version corrected
-- where clause when scope is 6 (i.e. PD pool)
RETURN;
END;\$\$;
--- Set 11.0 schema version.
+-- Update the schema version number.
UPDATE schema_version
SET version = '11', minor = '0';
--- Schema 11.0 specification ends here.
+-- This line concludes the schema upgrade to version 11.0.
-- Commit the script transaction.
COMMIT;
psql "$@" >/dev/null <<EOF
START TRANSACTION;
--- Upgrade to schema 12.0 begins here:
+-- This line starts the schema upgrade to version 12.0.
-- Modify shared-network-name foreign key constraint on dhcp4_subnet to not perform
-- the update when the network is deleted the cascaded update will not execute
ALTER TABLE dhcp4_client_class ADD COLUMN user_context JSON DEFAULT NULL;
ALTER TABLE dhcp6_client_class ADD COLUMN user_context JSON DEFAULT NULL;
--- Set 12.0 schema version.
+-- Update the schema version number.
UPDATE schema_version
SET version = '12', minor = '0';
--- Schema 12.0 specification ends here.
+-- This line concludes the schema upgrade to version 12.0.
-- Commit the script transaction.
COMMIT;
psql "$@" >/dev/null <<EOF
START TRANSACTION;
--- Upgrade to schema 13.0 begins here:
+-- This line starts the schema upgrade to version 13.0.
-- JSON functions --
(dhcp_identifier ASC, dhcp_identifier_type ASC, dhcp6_subnet_id ASC)
WHERE (dhcp6_subnet_id IS NOT NULL);
--- Set 13.0 schema version.
+-- Update the schema version number.
UPDATE schema_version
SET version = '13', minor = '0';
--- Schema 13.0 specification ends here.
+-- This line concludes the schema upgrade to version 13.0.
-- Commit the script transaction.
COMMIT;
psql "$@" >/dev/null <<EOF
START TRANSACTION;
--- Upgrade to schema 14.0 begins here:
+-- This line starts the schema upgrade to version 14.0.
-- Add cancelled (aka never-send) column to option tables.
ALTER TABLE dhcp4_client_class
ADD COLUMN offer_lifetime BIGINT DEFAULT NULL;
--- Set 14.0 schema version.
+-- Update the schema version number.
UPDATE schema_version
SET version = '14', minor = '0';
--- Schema 14.0 specification ends here.
+-- This line concludes the schema upgrade to version 14.0.
-- Commit the script transaction.
COMMIT;
psql "$@" >/dev/null <<EOF
START TRANSACTION;
--- Upgrade to schema 15.0 begins here:
+-- This line starts the schema upgrade to version 15.0.
-- Add relay and remote id columns to DHCPv4 leases.
--
CREATE INDEX lease4_by_relay_id ON lease4 (relay_id);
CREATE INDEX lease4_by_remote_id ON lease4 (remote_id);
--- Set 15.0 schema version.
+-- Update the schema version number.
UPDATE schema_version
SET version = '15', minor = '0';
--- Schema 15.0 specification ends here.
+-- This line concludes the schema upgrade to version 15.0.
-- Commit the script transaction.
COMMIT;
psql "$@" >/dev/null <<EOF
START TRANSACTION;
--- Upgrade to schema 16.0 begins here:
+-- This line starts the schema upgrade to version 16.0.
-- Add the allocator column to the DHCPv4 tables.
ALTER TABLE dhcp4_subnet ADD COLUMN allocator TEXT DEFAULT NULL;
ALTER TABLE dhcp6_shared_network ADD COLUMN allocator TEXT DEFAULT NULL;
ALTER TABLE dhcp6_shared_network ADD COLUMN pd_allocator TEXT DEFAULT NULL;
--- Set 16.0 schema version.
+-- Update the schema version number.
UPDATE schema_version
SET version = '16', minor = '0';
--- Schema 16.0 specification ends here.
+-- This line concludes the schema upgrade to version 16.0.
-- Commit the script transaction.
COMMIT;
psql "$@" >/dev/null <<EOF
START TRANSACTION;
--- Upgrade to schema 17.0 begins here:
+-- This line starts the schema upgrade to version 17.0.
UPDATE lease6 SET duid = E'\\\\x000000' WHERE duid = E'\\\\x00';
--- Set 17.0 schema version.
+-- Update the schema version number.
UPDATE schema_version
SET version = '17', minor = '0';
--- Schema 17.0 specification ends here.
+-- This line concludes the schema upgrade to version 17.0.
-- Commit the script transaction.
COMMIT;