|
@@ -28,53 +28,63 @@
|
|
|
#
|
|
|
# source dhcpdb_create.mysql
|
|
|
|
|
|
+
|
|
|
# Holds the IPv4 leases.
|
|
|
CREATE TABLE lease4 (
|
|
|
- address INT UNSIGNED UNIQUE NOT NULL, # IPv4 address
|
|
|
- hwaddr VARBINARY(20), # Hardware address
|
|
|
- client_id VARBINARY(128), # Client ID
|
|
|
- lease_time INT UNSIGNED, # Length of the lease (seconds)
|
|
|
- expire TIMESTAMP, # Expiration time of the lease
|
|
|
- subnet_id INT UNSIGNED # Subnet identification
|
|
|
+ address INT UNSIGNED PRIMARY KEY NOT NULL, # IPv4 address
|
|
|
+ hwaddr VARBINARY(20), # Hardware address
|
|
|
+ client_id VARBINARY(128), # Client ID
|
|
|
+ lease_time INT UNSIGNED, # Length of the lease (seconds)
|
|
|
+ expire TIMESTAMP, # Expiration time of the lease
|
|
|
+ subnet_id INT UNSIGNED # Subnet identification
|
|
|
) ENGINE = INNODB;
|
|
|
|
|
|
-# Holds the IPv6 leases
|
|
|
+# Holds the IPv6 leases.
|
|
|
+# N.B. The use of a VARCHAR for the address is temporary for development:
|
|
|
+# it will eventually be replaced by BINARY(16).
|
|
|
CREATE TABLE lease6 (
|
|
|
- address VARCHAR(40) UNIQUE NOT NULL, # IPv6 address (actually 39 is max)
|
|
|
- hwaddr VARBINARY(20), # Hardware address
|
|
|
- client_id VARBINARY(128), # Client ID
|
|
|
- lease_time INT UNSIGNED, # Length of the lease (seconds)
|
|
|
- expire TIMESTAMP, # Expiration time of the lease
|
|
|
- subnet_id INT UNSIGNED, # Subnet identification
|
|
|
- pref_lifetime INT UNSIGNED, # Preferred lifetime
|
|
|
- lease_type TINYINT, # Lease type
|
|
|
- iaid INT UNSIGNED, # IA ID
|
|
|
- prefix_len TINYINT UNSIGNED # For IA_PD only
|
|
|
+ address VARCHAR(40) PRIMARY KEY NOT NULL, # IPv6 address
|
|
|
+ hwaddr VARBINARY(20), # Hardware address
|
|
|
+ client_id VARBINARY(128), # Client ID
|
|
|
+ lease_time INT UNSIGNED, # Length of the lease (seconds)
|
|
|
+ expire TIMESTAMP, # Expiration time of the lease
|
|
|
+ subnet_id INT UNSIGNED, # Subnet identification
|
|
|
+ pref_lifetime INT UNSIGNED, # Preferred lifetime
|
|
|
+ lease_type TINYINT, # Lease type (see lease6_types
|
|
|
+ # table for possible values)
|
|
|
+ iaid INT UNSIGNED, # See Section 10 of RFC 3315
|
|
|
+ prefix_len TINYINT UNSIGNED # For IA_PD only
|
|
|
) ENGINE = INNODB;
|
|
|
|
|
|
# ... and a definition of lease6 types. This table is a convenience for
|
|
|
# users of the database - if they want to view the lease table and use the
|
|
|
# type names, they can join this table with the lease6 table
|
|
|
CREATE TABLE lease6_types (
|
|
|
- lease_type TINYINT UNIQUE NOT NULL, # Lease type code
|
|
|
- name VARCHAR(5) # Name of the lease type
|
|
|
+ lease_type TINYINT PRIMARY KEY NOT NULL, # Lease type code.
|
|
|
+ name VARCHAR(5) # Name of the lease type
|
|
|
);
|
|
|
+START TRANSACTION;
|
|
|
INSERT INTO lease6_types VALUES (0, "IA_NA"); # Non-temporary v6 addresses
|
|
|
INSERT INTO lease6_types VALUES (1, "IA_TA"); # Temporary v6 addresses
|
|
|
INSERT INTO lease6_types VALUES (2, "IA_PD"); # Prefix delegations
|
|
|
+COMMIT;
|
|
|
|
|
|
# Finally, the version of the schema. We start at 0.1 during development.
|
|
|
# This table is only modified during schema upgrades. For historical reasons
|
|
|
# (related to the names of the columns in the BIND 10 DNS database file), the
|
|
|
# first column is called "version" and not "major".
|
|
|
CREATE TABLE schema_version (
|
|
|
- version INT NOT NULL, # Major version number
|
|
|
- minor INT NOT NULL # Minor version number
|
|
|
+ version INT PRIMARY KEY NOT NULL, # Major version number
|
|
|
+ minor INT # Minor version number
|
|
|
);
|
|
|
+START TRANSACTION;
|
|
|
INSERT INTO schema_version VALUES (0, 1);
|
|
|
-
|
|
|
COMMIT;
|
|
|
|
|
|
+# Notes:
|
|
|
+#
|
|
|
+# Indexes
|
|
|
+# =======
|
|
|
# It is likely that additional indexes will be needed. However, the
|
|
|
# increase in lookup performance from these will come at the expense
|
|
|
# of a decrease in performance during insert operations due to the need
|
|
@@ -90,3 +100,17 @@ COMMIT;
|
|
|
# For lease stability: if a client requests a new lease, try to find an
|
|
|
# existing or recently expired lease for it so that it can keep using the
|
|
|
# same IP address.
|
|
|
+#
|
|
|
+# Field Sizes
|
|
|
+# ===========
|
|
|
+# If any of the VARxxx field sizes are altered, the lengths in the MySQL
|
|
|
+# backend source file (mysql_lease_mgr.cc) must be correspondingly changed.
|
|
|
+#
|
|
|
+# Portability
|
|
|
+# ===========
|
|
|
+# The "ENGINE = INNODB" on some tables is not portablea to another database
|
|
|
+# and will need to be removed.
|
|
|
+#
|
|
|
+# Some columns contain binary data so are stored as VARBINARY instead of
|
|
|
+# VARCHAR. This may be non-portable between databases: in this case, the
|
|
|
+# definition should be changed to VARCHAR.
|