mirror of
https://gitlab.isc.org/isc-projects/kea
synced 2025-08-31 22:15:23 +00:00
[3968] Updated PostgreSQL schema per review comments.
This commit is contained in:
@@ -119,8 +119,8 @@ ALTER TABLE lease6
|
|||||||
-- by the expiration time. One of the applications is to retrieve all
|
-- by the expiration time. One of the applications is to retrieve all
|
||||||
-- expired leases. However, these indexes can be also used to retrieve
|
-- expired leases. However, these indexes can be also used to retrieve
|
||||||
-- leases in a given state regardless of the expiration time.
|
-- leases in a given state regardless of the expiration time.
|
||||||
CREATE INDEX lease4_by_state_expire ON lease4 (state, expire);
|
CREATE INDEX lease4_by_state_expire ON lease4 (state ASC, expire ASC);
|
||||||
CREATE INDEX lease6_by_state_expire ON lease6 (state, expire);
|
CREATE INDEX lease6_by_state_expire ON lease6 (state ASC, expire ASC);
|
||||||
|
|
||||||
-- Create table holding mapping of the lease states to their names.
|
-- Create table holding mapping of the lease states to their names.
|
||||||
-- This is not used in queries from the DHCP server but rather in
|
-- This is not used in queries from the DHCP server but rather in
|
||||||
@@ -136,6 +136,24 @@ INSERT INTO lease_state VALUES (1, 'declined');
|
|||||||
INSERT INTO lease_state VALUES (2, 'expired-reclaimed');
|
INSERT INTO lease_state VALUES (2, 'expired-reclaimed');
|
||||||
COMMIT;
|
COMMIT;
|
||||||
|
|
||||||
|
-- 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);
|
||||||
|
|
||||||
--
|
--
|
||||||
-- FUNCTION that returns a result set containing the column names for lease4 dumps
|
-- FUNCTION that returns a result set containing the column names for lease4 dumps
|
||||||
DROP FUNCTION IF EXISTS lease4DumpHeader();
|
DROP FUNCTION IF EXISTS lease4DumpHeader();
|
||||||
|
@@ -1,4 +1,4 @@
|
|||||||
// Copyright (C) 2014 Internet Systems Consortium, Inc. ("ISC")
|
// Copyright (C) 2014-2015 Internet Systems Consortium, Inc. ("ISC")
|
||||||
//
|
//
|
||||||
// Permission to use, copy, modify, and/or distribute this software for any
|
// Permission to use, copy, modify, and/or distribute this software for any
|
||||||
// purpose with or without fee is hereby granted, provided that the above
|
// purpose with or without fee is hereby granted, provided that the above
|
||||||
@@ -97,8 +97,8 @@ const char* create_statement[] = {
|
|||||||
"ALTER TABLE lease6 "
|
"ALTER TABLE lease6 "
|
||||||
"ADD COLUMN state INT8 DEFAULT 0",
|
"ADD COLUMN state INT8 DEFAULT 0",
|
||||||
|
|
||||||
"CREATE INDEX lease4_by_state_expire ON lease4 (state, expire)",
|
"CREATE INDEX lease4_by_state_expire ON lease4 (state ASC, expire ASC)",
|
||||||
"CREATE INDEX lease6_by_state_expire ON lease6 (state, expire)",
|
"CREATE INDEX lease6_by_state_expire ON lease6 (state ASC, expire ASC)",
|
||||||
|
|
||||||
// Production schema includes the lease_state table which maps
|
// Production schema includes the lease_state table which maps
|
||||||
// the lease states to their names. This is not used in the unit tests
|
// the lease states to their names. This is not used in the unit tests
|
||||||
@@ -108,6 +108,18 @@ const char* create_statement[] = {
|
|||||||
"state INT8 PRIMARY KEY NOT NULL,"
|
"state INT8 PRIMARY KEY NOT NULL,"
|
||||||
"name VARCHAR(64) NOT NULL);",
|
"name VARCHAR(64) NOT NULL);",
|
||||||
|
|
||||||
|
"ALTER TABLE lease4 "
|
||||||
|
"ADD CONSTRAINT fk_lease4_state FOREIGN KEY (state) "
|
||||||
|
"REFERENCES lease_state (state)",
|
||||||
|
|
||||||
|
"ALTER TABLE lease6 "
|
||||||
|
"ADD CONSTRAINT fk_lease6_state FOREIGN KEY (state) "
|
||||||
|
"REFERENCES lease_state (state)",
|
||||||
|
|
||||||
|
"ALTER TABLE lease6 "
|
||||||
|
"ADD CONSTRAINT fk_lease6_type FOREIGN KEY (lease_type) "
|
||||||
|
"REFERENCES lease6_types (lease_type)",
|
||||||
|
|
||||||
"INSERT INTO lease_state VALUES (0, \"default\");",
|
"INSERT INTO lease_state VALUES (0, \"default\");",
|
||||||
"INSERT INTO lease_state VALUES (1, \"declined\");",
|
"INSERT INTO lease_state VALUES (1, \"declined\");",
|
||||||
"INSERT INTO lease_state VALUES (2, \"expired-reclaimed\");",*/
|
"INSERT INTO lease_state VALUES (2, \"expired-reclaimed\");",*/
|
||||||
|
Reference in New Issue
Block a user