mirror of
https://gitlab.isc.org/isc-projects/kea
synced 2025-09-01 14:35:29 +00:00
[3968] Added additional constraints to mysql creation script.
This commit is contained in:
@@ -273,7 +273,36 @@ CREATE INDEX lease6_by_state_expire ON lease6 (state, expire);
|
|||||||
# direct queries from the lease database management tools.
|
# direct queries from the lease database management tools.
|
||||||
CREATE TABLE IF NOT EXISTS lease_state (
|
CREATE TABLE IF NOT EXISTS lease_state (
|
||||||
state INT UNSIGNED PRIMARY KEY NOT NULL,
|
state INT UNSIGNED PRIMARY KEY NOT NULL,
|
||||||
name VARCHAR(64) NOT NULL);
|
name VARCHAR(64) NOT NULL
|
||||||
|
) ENGINE=INNODB;
|
||||||
|
|
||||||
|
# Add a constraint that any state value added to the lease4 must
|
||||||
|
# map to a value in the lease_state table.
|
||||||
|
ALTER TABLE lease4
|
||||||
|
ADD CONSTRAINT fk_lease4_state FOREIGN KEY (state)
|
||||||
|
REFERENCES lease_state (state);
|
||||||
|
|
||||||
|
# Add a constraint that any state value added to the lease6 must
|
||||||
|
# map to a value in the lease_state table.
|
||||||
|
ALTER TABLE lease6
|
||||||
|
ADD CONSTRAINT fk_lease6_state FOREIGN KEY (state)
|
||||||
|
REFERENCES lease_state (state);
|
||||||
|
|
||||||
|
# Add a constraint that lease type in the lease6 table must map
|
||||||
|
# to a lease type defined in the lease6_types table.
|
||||||
|
ALTER TABLE lease6
|
||||||
|
ADD CONSTRAINT fk_lease6_type FOREIGN KEY (lease_type)
|
||||||
|
REFERENCES lease6_types (lease_type);
|
||||||
|
|
||||||
|
# Add UNSIGNED to match with the lease6.
|
||||||
|
ALTER TABLE lease_hwaddr_source
|
||||||
|
MODIFY COLUMN hwaddr_source INT UNSIGNED NOT NULL DEFAULT 0;
|
||||||
|
|
||||||
|
# Add a constraint that non-null hwaddr_source in the lease6 table
|
||||||
|
# must map to an entry in the lease_hwaddr_source.
|
||||||
|
ALTER TABLE lease6
|
||||||
|
ADD CONSTRAINT fk_lease6_hwaddr_source FOREIGN KEY (hwaddr_source)
|
||||||
|
REFERENCES lease_hwaddr_source (hwaddr_source);
|
||||||
|
|
||||||
# Insert currently defined state names.
|
# Insert currently defined state names.
|
||||||
INSERT INTO lease_state VALUES (0, "default");
|
INSERT INTO lease_state VALUES (0, "default");
|
||||||
|
Reference in New Issue
Block a user