}
mysql_upgrade_30_to_31_test() {
- # Check dhcp4.client_classes now needs a value
+ # Check dhcp4_options.client_classes now needs a value
qry="SET @disable_audit = 1;\
INSERT INTO dhcp4_options (scope_id, code, space, formatted_value, modification_ts) \
VALUES (0, '223', 'dhcp4', 'foo' , current_timestamp );";
run_command \
mysql_execute "${qry}"
assert_eq 1 "${EXIT_CODE}" "${qry}: expected %d, returned %d"
+
+ # Check dhcp6_options.client_classes now needs a value
+ qry="SET @disable_audit = 1;\
+ INSERT INTO dhcp6_options (scope_id, code, space, formatted_value, modification_ts) \
+ VALUES (0, '223', 'dhcp6', 'foo' , current_timestamp );";
+
+ # Should fail with "ERROR 1364 (HY000): Field 'client_classes' doesn't have a default value"
+ run_command \
+ mysql_execute "${qry}"
+ assert_eq 1 "${EXIT_CODE}" "${qry}: expected %d, returned %d"
}
mysql_upgrade_test() {
test_finish 0
}
-# Verifies migration of dhcp4_options.client_classes column to not null.
-mysql_migrate_dhcp4_options_client_classes() {
+# Verifies migration of dhcpX_options.client_classes column to not null.
+mysql_migrate_dhcpX_options_client_classes() {
test_start "mysql.mysql_migrate_dhcp4_options_client_classes"
# Let's wipe the whole database
values (0, 222, 'dhcp4', 'foo' , current_timestamp); \
insert into dhcp4_options \
(scope_id, code, space, formatted_value, client_classes, modification_ts) \
- values (0, 223, 'dhcp4', 'bar' , '[ \"cc-one\" ]', current_timestamp);"
+ values (0, 223, 'dhcp4', 'bar' , '[ \"cc-one\" ]', current_timestamp);
+ insert into dhcp6_options \
+ (scope_id, code, space, formatted_value, modification_ts) \
+ values (0, 222, 'dhcp6', 'foo' , current_timestamp); \
+ insert into dhcp6_options \
+ (scope_id, code, space, formatted_value, client_classes, modification_ts) \
+ values (0, 223, 'dhcp6', 'bar' , '[ \"cc-one\" ]', current_timestamp);"
run_statement "insert option" "$sql"
# Verify the inserted record counts.
qry="select count(*) from dhcp4_options;"
run_statement "#get 4_option_count before update" "$qry" 2
+ qry="select count(*) from dhcp6_options;"
+ run_statement "#get 6_option_count before update" "$qry" 2
# Upgrade to schema 31.0
mysql_upgrade_schema_to_version 31.0
# Verify the migrated records.
qry="select code from dhcp4_options where client_classes = '[ ]';"
- run_statement "#get 4_option_222 after update" "$qry" 222
+ run_statement "#get 4_option_222 after update" "$qry" 222
qry="select code from dhcp4_options where client_classes = '[ \"cc-one\" ]';"
- run_statement "#get 4_option_223 after update" "$qry" 223
+ run_statement "#get 4_option_223 after update" "$qry" 223
+
+ qry="select code from dhcp6_options where client_classes = '[ ]';"
+ run_statement "#get 6_option_222 after update" "$qry" 222
+
+ qry="select code from dhcp6_options where client_classes = '[ \"cc-one\" ]';"
+ run_statement "#get 6_option_223 after update" "$qry" 223
# Let's wipe the whole database
mysql_wipe
mysql_migrate_opt_record_type
mysql_remove_control_socket_parameters_test
mysql_migrate_client_class_test
-mysql_migrate_dhcp4_options_client_classes
+mysql_migrate_dhcpX_options_client_classes
}
pgsql_upgrade_29_to_30_test() {
- # Check dhcp4.client_classes now needs a value
+ # Check dhcp4_options.client_classes now needs a value
qry="SELECT set_config('kea.disable_audit', 'true', false);\
INSERT INTO dhcp4_options (scope_id, code, space, formatted_value, modification_ts) \
VALUES (0, '223', 'dhcp4', 'foo' , current_timestamp );";
run_command \
pgsql_execute "${qry}"
assert_eq 3 "${EXIT_CODE}" "${qry}: expected %d, returned %d"
+
+ # Check dhcp6_options.client_classes now needs a value
+ qry="SELECT set_config('kea.disable_audit', 'true', false);\
+ INSERT INTO dhcp6_options (scope_id, code, space, formatted_value, modification_ts) \
+ VALUES (0, '223', 'dhcp6', 'foo' , current_timestamp );";
+
+ # Should fail with "# ERROR: null value in column "client_classes" of relation "dhcp6_options"
+ # violates not-null constraint"
+ run_command \
+ pgsql_execute "${qry}"
+ assert_eq 3 "${EXIT_CODE}" "${qry}: expected %d, returned %d"
}
pgsql_upgrade_test() {
test_finish 0
}
-# Verifies migration of dhcp4_options.client_classes column to not null.
-pgsql_migrate_dhcp4_options_client_classes() {
- test_start "pgsql.pgsql_migrate_dhcp4_options_client_classes"
+# Verifies migration of dhcpX_options.client_classes column to not null.
+pgsql_migrate_dhcpX_options_client_classes() {
+ test_start "pgsql.pgsql_migrate_dhcpX_options_client_classes"
# Let's wipe the whole database
pgsql_wipe
values (0, '222', 'dhcp4', 'foo' , current_timestamp); \
insert into dhcp4_options (scope_id, code, space, formatted_value, client_classes, modification_ts) \
values (0, '223', 'dhcp4', 'bar' , '[ \"cc-one\" ]', current_timestamp); \
+ insert into dhcp6_options (scope_id, code, space, formatted_value, modification_ts) \
+ values (0, '222', 'dhcp6', 'foo' , current_timestamp); \
+ insert into dhcp6_options (scope_id, code, space, formatted_value, client_classes, modification_ts) \
+ values (0, '223', 'dhcp6', 'bar' , '[ \"cc-one\" ]', current_timestamp); \
select set_config('kea.disable_audit', 'false', false);"
run_statement "insert option" "$sql"
qry="select count(*) from dhcp4_options;"
run_statement "#get 4_option_count before update" "$qry" 2
+ qry="select count(*) from dhcp6_options;"
+ run_statement "#get 6_option_count before update" "$qry" 2
+
# Upgrade to schema 30.0
pgsql_upgrade_schema_to_version 30.0
# Verify the migrated records.
qry="select code from dhcp4_options where client_classes = '[ ]';"
- run_statement "#get 4_option_foo after update" "$qry" 222
+ run_statement "#get 4_option_foo after update" "$qry" 222
qry="select code from dhcp4_options where client_classes = '[ \"cc-one\" ]';"
- run_statement "#get 4_option_foo after update" "$qry" 223
+ run_statement "#get 4_option_foo after update" "$qry" 223
+
+ qry="select code from dhcp6_options where client_classes = '[ ]';"
+ run_statement "#get 6_option_foo after update" "$qry" 222
+
+ qry="select code from dhcp6_options where client_classes = '[ \"cc-one\" ]';"
+ run_statement "#get 6_option_foo after update" "$qry" 223
# Let's wipe the whole database
pgsql_wipe
pgsql_migrate_opt_record_type
pgsql_remove_control_socket_parameters_test
pgsql_migrate_client_class_test
-pgsql_migrate_dhcp4_options_client_classes
+pgsql_migrate_dhcpX_options_client_classes
ALTER TABLE dhcp4_options ALTER COLUMN client_classes SET NOT NULL;
UPDATE dhcp6_options SET client_classes = '[ ]' WHERE client_classes IS NULL;
ALTER TABLE dhcp6_options ALTER COLUMN client_classes SET NOT NULL;
+ALTER TABLE dhcp6_options ADD COLUMN IF NOT EXISTS modification_ts TIMESTAMP
+ WITH TIME ZONE NOT NULL DEFAULT CURRENT_TIMESTAMP;
SELECT set_config('kea.disable_audit', 'false', false);
-- Update the schema version number.
ADD COLUMN shared_network_name VARCHAR(128) DEFAULT NULL,
ADD COLUMN pool_id BIGINT DEFAULT NULL,
ADD COLUMN pd_pool_id BIGINT DEFAULT NULL,
+ ADD COLUMN modification_ts TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT CURRENT_TIMESTAMP,
ADD CONSTRAINT fk_dhcp6_options_pd_pool FOREIGN KEY (pd_pool_id)
REFERENCES dhcp6_pd_pool(id) ON DELETE CASCADE ON UPDATE CASCADE,
ADD CONSTRAINT fk_dhcp6_options_pool FOREIGN KEY (pool_id)
ALTER TABLE dhcp4_options ALTER COLUMN client_classes SET NOT NULL;
UPDATE dhcp6_options SET client_classes = '[ ]' WHERE client_classes IS NULL;
ALTER TABLE dhcp6_options ALTER COLUMN client_classes SET NOT NULL;
+ALTER TABLE dhcp6_options ADD COLUMN IF NOT EXISTS modification_ts TIMESTAMP
+ WITH TIME ZONE NOT NULL DEFAULT CURRENT_TIMESTAMP;
SELECT set_config('kea.disable_audit', 'false', false);
-- Update the schema version number.