"VALUES (?,?,?,?,?)"},
// Inserts a single DHCPv4 option into 'dhcp4_options' table.
+ // Using fixed scope_id = 3, which associates an option with host.
{MySqlHostDataSourceImpl::INSERT_V4_OPTION,
"INSERT INTO dhcp4_options(option_id, code, value, formatted_value, space, "
- "persistent, dhcp_client_class, dhcp4_subnet_id, host_id) "
- " VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)"},
+ "persistent, dhcp_client_class, dhcp4_subnet_id, host_id, scope_id) "
+ " VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, 3)"},
// Inserts a single DHCPv6 option into 'dhcp6_options' table.
+ // Using fixed scope_id = 3, which associates an option with host.
{MySqlHostDataSourceImpl::INSERT_V6_OPTION,
"INSERT INTO dhcp6_options(option_id, code, value, formatted_value, space, "
- "persistent, dhcp_client_class, dhcp6_subnet_id, host_id) "
- " VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)"},
+ "persistent, dhcp_client_class, dhcp6_subnet_id, host_id, scope_id) "
+ " VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, 3)"},
// Retrieves host information, IPv6 reservations and both DHCPv4 and
// DHCPv6 options associated with the host. The LEFT JOIN clause is used
ALTER TABLE dhcp4_options MODIFY dhcp4_subnet_id INT UNSIGNED NULL;
ALTER TABLE dhcp6_options MODIFY dhcp6_subnet_id INT UNSIGNED NULL;
+# Scopes associate DHCP options stored in dhcp4_options and
+# dhcp6_options tables with hosts, subnets, classes or indicate
+# that they are global options.
+CREATE TABLE IF NOT EXISTS dhcp_option_scope (
+ scope_id TINYINT UNSIGNED PRIMARY KEY NOT NULL,
+ scope_name VARCHAR(32)
+) ENGINE = INNODB;
+
+START TRANSACTION;
+INSERT INTO dhcp_option_scope VALUES (0, "global");
+INSERT INTO dhcp_option_scope VALUES (1, "subnet");
+INSERT INTO dhcp_option_scope VALUES (2, "client-class");
+INSERT INTO dhcp_option_scope VALUES (3, "host");
+COMMIT;
+
+# Add scopes into table holding DHCPv4 options
+ALTER TABLE dhcp4_options ADD COLUMN scope_id TINYINT UNSIGNED NOT NULL;
+ALTER TABLE dhcp4_options
+ ADD CONSTRAINT fk_dhcp4_option_scope FOREIGN KEY (scope_id)
+ REFERENCES dhcp_option_scope (scope_id);
+
+# Add scopes into table holding DHCPv6 options
+ALTER TABLE dhcp6_options ADD COLUMN scope_id TINYINT UNSIGNED NOT NULL;
+ALTER TABLE dhcp6_options
+ ADD CONSTRAINT fk_dhcp6_option_scope FOREIGN KEY (scope_id)
+ REFERENCES dhcp_option_scope (scope_id);
+
# Update the schema version number
UPDATE schema_version
SET version = '4', minor = '2';