diff --git a/doc/02-Installation.md b/doc/02-Installation.md index a8e9a759..40d4e00b 100644 --- a/doc/02-Installation.md +++ b/doc/02-Installation.md @@ -65,10 +65,6 @@ command. GRANT ALL PRIVILEGES ON DATABASE director TO director; CREATE EXTENSION pgcrypto;" -Hint: pgcrypto helps to boost performance, but is currently optional. In case you -do not have it available on your platform and/or do not know how to solve this -just leave away the 'CREATE EXTENSION' part. - Web-based Configuration ----------------------- diff --git a/doc/82-Changelog.md b/doc/82-Changelog.md index d4362a70..53d2bd90 100644 --- a/doc/82-Changelog.md +++ b/doc/82-Changelog.md @@ -14,6 +14,9 @@ next (will be 1.9.1) ### User Interface * FIX: DataList-backed fields failed to validate (#2475) +### DB Schema +* FIX: applying DB Schema migrations failed on PostgreSQL (#2482) + 1.9.0 ----- diff --git a/schema/pgsql-migrations/upgrade_174.sql b/schema/pgsql-migrations/upgrade_174.sql index b1488a8a..9b5c7ef5 100644 --- a/schema/pgsql-migrations/upgrade_174.sql +++ b/schema/pgsql-migrations/upgrade_174.sql @@ -1,72 +1,60 @@ +ALTER TABLE icinga_zone DROP COLUMN IF EXISTS uuid; + ALTER TABLE icinga_zone ADD COLUMN uuid bytea UNIQUE CHECK(LENGTH(uuid) = 16); UPDATE icinga_zone SET uuid = decode(replace(gen_random_uuid()::text, '-', ''), 'hex') WHERE uuid IS NULL; ALTER TABLE icinga_zone ALTER COLUMN uuid SET NOT NULL; -CREATE UNIQUE INDEX zone_uuid ON icinga_zone (uuid); ALTER TABLE icinga_timeperiod ADD COLUMN uuid bytea UNIQUE CHECK(LENGTH(uuid) = 16); UPDATE icinga_timeperiod SET uuid = decode(replace(gen_random_uuid()::text, '-', ''), 'hex') WHERE uuid IS NULL; ALTER TABLE icinga_timeperiod ALTER COLUMN uuid SET NOT NULL; -CREATE UNIQUE INDEX timeperiod_uuid ON icinga_timeperiod (uuid); ALTER TABLE icinga_command ADD COLUMN uuid bytea UNIQUE CHECK(LENGTH(uuid) = 16); UPDATE icinga_command SET uuid = decode(replace(gen_random_uuid()::text, '-', ''), 'hex') WHERE uuid IS NULL; ALTER TABLE icinga_command ALTER COLUMN uuid SET NOT NULL; -CREATE UNIQUE INDEX command_uuid ON icinga_command (uuid); ALTER TABLE icinga_apiuser ADD COLUMN uuid bytea UNIQUE CHECK(LENGTH(uuid) = 16); UPDATE icinga_apiuser SET uuid = decode(replace(gen_random_uuid()::text, '-', ''), 'hex') WHERE uuid IS NULL; ALTER TABLE icinga_apiuser ALTER COLUMN uuid SET NOT NULL; -CREATE UNIQUE INDEX apiuser_uuid ON icinga_apiuser (uuid); ALTER TABLE icinga_endpoint ADD COLUMN uuid bytea UNIQUE CHECK(LENGTH(uuid) = 16); UPDATE icinga_endpoint SET uuid = decode(replace(gen_random_uuid()::text, '-', ''), 'hex') WHERE uuid IS NULL; ALTER TABLE icinga_endpoint ALTER COLUMN uuid SET NOT NULL; -CREATE UNIQUE INDEX endpoint_uuid ON icinga_endpoint (uuid); ALTER TABLE icinga_host ADD COLUMN uuid bytea UNIQUE CHECK(LENGTH(uuid) = 16); UPDATE icinga_host SET uuid = decode(replace(gen_random_uuid()::text, '-', ''), 'hex') WHERE uuid IS NULL; ALTER TABLE icinga_host ALTER COLUMN uuid SET NOT NULL; -CREATE UNIQUE INDEX host_uuid ON icinga_host (uuid); ALTER TABLE icinga_service ADD COLUMN uuid bytea UNIQUE CHECK(LENGTH(uuid) = 16); UPDATE icinga_service SET uuid = decode(replace(gen_random_uuid()::text, '-', ''), 'hex') WHERE uuid IS NULL; ALTER TABLE icinga_service ALTER COLUMN uuid SET NOT NULL; -CREATE UNIQUE INDEX service_uuid ON icinga_service (uuid); ALTER TABLE icinga_hostgroup ADD COLUMN uuid bytea UNIQUE CHECK(LENGTH(uuid) = 16); UPDATE icinga_hostgroup SET uuid = decode(replace(gen_random_uuid()::text, '-', ''), 'hex') WHERE uuid IS NULL; ALTER TABLE icinga_hostgroup ALTER COLUMN uuid SET NOT NULL; -CREATE UNIQUE INDEX hostgroup_uuid ON icinga_hostgroup (uuid); ALTER TABLE icinga_servicegroup ADD COLUMN uuid bytea UNIQUE CHECK(LENGTH(uuid) = 16); UPDATE icinga_servicegroup SET uuid = decode(replace(gen_random_uuid()::text, '-', ''), 'hex') WHERE uuid IS NULL; ALTER TABLE icinga_servicegroup ALTER COLUMN uuid SET NOT NULL; -CREATE UNIQUE INDEX servicegroup_uuid ON icinga_servicegroup (uuid); ALTER TABLE icinga_user ADD COLUMN uuid bytea UNIQUE CHECK(LENGTH(uuid) = 16); UPDATE icinga_user SET uuid = decode(replace(gen_random_uuid()::text, '-', ''), 'hex') WHERE uuid IS NULL; ALTER TABLE icinga_user ALTER COLUMN uuid SET NOT NULL; -CREATE UNIQUE INDEX user_uuid ON icinga_user (uuid); ALTER TABLE icinga_usergroup ADD COLUMN uuid bytea UNIQUE CHECK(LENGTH(uuid) = 16); UPDATE icinga_usergroup SET uuid = decode(replace(gen_random_uuid()::text, '-', ''), 'hex') WHERE uuid IS NULL; ALTER TABLE icinga_usergroup ALTER COLUMN uuid SET NOT NULL; -CREATE UNIQUE INDEX usergroup_uuid ON icinga_usergroup (uuid); ALTER TABLE icinga_notification ADD COLUMN uuid bytea UNIQUE CHECK(LENGTH(uuid) = 16); UPDATE icinga_notification SET uuid = decode(replace(gen_random_uuid()::text, '-', ''), 'hex') WHERE uuid IS NULL; ALTER TABLE icinga_notification ALTER COLUMN uuid SET NOT NULL; -CREATE UNIQUE INDEX notification_uuid ON icinga_notification (uuid); ALTER TABLE icinga_dependency ADD COLUMN uuid bytea UNIQUE CHECK(LENGTH(uuid) = 16); UPDATE icinga_dependency SET uuid = decode(replace(gen_random_uuid()::text, '-', ''), 'hex') WHERE uuid IS NULL; ALTER TABLE icinga_dependency ALTER COLUMN uuid SET NOT NULL; -CREATE UNIQUE INDEX dependency_uuid ON icinga_dependency (uuid); ALTER TABLE icinga_scheduled_downtime ADD COLUMN uuid bytea UNIQUE CHECK(LENGTH(uuid) = 16); UPDATE icinga_scheduled_downtime SET uuid = decode(replace(gen_random_uuid()::text, '-', ''), 'hex') WHERE uuid IS NULL; ALTER TABLE icinga_scheduled_downtime ALTER COLUMN uuid SET NOT NULL; -CREATE UNIQUE INDEX scheduled_downtime_uuid ON icinga_scheduled_downtime (uuid); INSERT INTO director_schema_migration (schema_version, migration_time) diff --git a/schema/pgsql.sql b/schema/pgsql.sql index 711390f9..1fbe9e9e 100644 --- a/schema/pgsql.sql +++ b/schema/pgsql.sql @@ -346,7 +346,6 @@ CREATE TABLE icinga_zone ( ); CREATE INDEX zone_parent ON icinga_zone (parent_id); -CREATE UNIQUE INDEX zone_uuid ON icinga_zone (uuid); CREATE TABLE icinga_zone_inheritance ( @@ -389,7 +388,6 @@ CREATE TABLE icinga_timeperiod ( ON UPDATE CASCADE ); -CREATE UNIQUE INDEX timeperiod_uuid ON icinga_timeperiod (uuid); CREATE UNIQUE INDEX timeperiod_object_name ON icinga_timeperiod (object_name, zone_id); CREATE INDEX timeperiod_zone ON icinga_timeperiod (zone_id); COMMENT ON COLUMN icinga_timeperiod.update_method IS 'Usually LegacyTimePeriod'; @@ -495,7 +493,6 @@ CREATE TABLE icinga_command ( ON UPDATE CASCADE ); -CREATE UNIQUE INDEX command_uuid ON icinga_command (uuid); CREATE UNIQUE INDEX command_object_name ON icinga_command (object_name); CREATE INDEX command_zone ON icinga_command (zone_id); COMMENT ON COLUMN icinga_command.object_type IS 'external_object is an attempt to work with existing commands'; @@ -603,7 +600,6 @@ CREATE TABLE icinga_apiuser ( PRIMARY KEY (id) ); -CREATE UNIQUE INDEX apiuser_uuid ON icinga_apiuser (uuid); COMMENT ON COLUMN icinga_apiuser.permissions IS 'JSON-encoded permissions'; @@ -631,7 +627,6 @@ CREATE TABLE icinga_endpoint ( ON UPDATE CASCADE ); -CREATE UNIQUE INDEX endpoint_uuid ON icinga_endpoint (uuid); CREATE UNIQUE INDEX endpoint_object_name ON icinga_endpoint (object_name); CREATE INDEX endpoint_zone ON icinga_endpoint (zone_id); COMMENT ON COLUMN icinga_endpoint.host IS 'IP address / hostname of remote node'; @@ -747,7 +742,6 @@ CREATE TABLE icinga_host ( ); -CREATE UNIQUE INDEX host_uuid ON icinga_host (uuid); CREATE UNIQUE INDEX object_name_host ON icinga_host (object_name, zone_id); CREATE UNIQUE INDEX host_api_key ON icinga_host (api_key); CREATE INDEX host_zone ON icinga_host (zone_id); @@ -849,7 +843,6 @@ CREATE TABLE icinga_service_set ( CREATE UNIQUE INDEX service_set_name ON icinga_service_set (object_name, host_id); CREATE INDEX service_set_host ON icinga_service_set (host_id); -CREATE UNIQUE INDEX service_set_uuid ON icinga_service_set (uuid); CREATE TABLE icinga_service_template_choice ( @@ -948,7 +941,6 @@ CREATE TABLE icinga_service ( ON UPDATE CASCADE ); -CREATE UNIQUE INDEX service_uuid ON icinga_service (uuid); CREATE INDEX service_zone ON icinga_service (zone_id); CREATE INDEX service_timeperiod ON icinga_service (check_period_id); CREATE INDEX service_check_command ON icinga_service (check_command_id); @@ -1122,7 +1114,6 @@ CREATE TABLE icinga_hostgroup ( PRIMARY KEY (id) ); -CREATE UNIQUE INDEX hostgroup_uuid ON icinga_hostgroup (uuid); CREATE UNIQUE INDEX hostgroup_object_name ON icinga_hostgroup (object_name); CREATE INDEX hostgroup_search_idx ON icinga_hostgroup (display_name); @@ -1161,7 +1152,6 @@ CREATE TABLE icinga_servicegroup ( PRIMARY KEY (id) ); -CREATE UNIQUE INDEX servicegroup_uuid ON icinga_servicegroup (uuid); CREATE UNIQUE INDEX servicegroup_object_name ON icinga_servicegroup (object_name); CREATE INDEX servicegroup_search_idx ON icinga_servicegroup (display_name); @@ -1312,7 +1302,6 @@ CREATE TABLE icinga_user ( ON UPDATE CASCADE ); -CREATE UNIQUE INDEX user_uuid ON icinga_user (uuid); CREATE UNIQUE INDEX user_object_name ON icinga_user (object_name, zone_id); CREATE INDEX user_zone ON icinga_user (zone_id); @@ -1430,7 +1419,6 @@ CREATE TABLE icinga_usergroup ( ON UPDATE CASCADE ); -CREATE UNIQUE INDEX usergroup_uuid ON icinga_usergroup (uuid); CREATE UNIQUE INDEX usergroup_search_idx ON icinga_usergroup (display_name); CREATE INDEX usergroup_object_name ON icinga_usergroup (object_name); CREATE INDEX usergroup_zone ON icinga_usergroup (zone_id); @@ -1542,8 +1530,6 @@ CREATE TABLE icinga_notification ( ON UPDATE CASCADE ); -CREATE UNIQUE INDEX notification_uuid ON icinga_notification (uuid); - CREATE TABLE icinga_notification_user ( notification_id integer NOT NULL, @@ -2102,7 +2088,6 @@ CREATE TABLE icinga_dependency ( ON UPDATE CASCADE ); -CREATE UNIQUE INDEX dependency_uuid ON icinga_dependency (uuid); CREATE INDEX dependency_parent_host ON icinga_dependency (parent_host_id); CREATE INDEX dependency_parent_service ON icinga_dependency (parent_service_id); CREATE INDEX dependency_child_host ON icinga_dependency (child_host_id); @@ -2203,7 +2188,6 @@ CREATE TABLE icinga_scheduled_downtime ( ON UPDATE CASCADE ); -CREATE UNIQUE INDEX scheduled_downtime_uuid ON icinga_scheduled_downtime (uuid); CREATE UNIQUE INDEX scheduled_downtime_object_name ON icinga_scheduled_downtime (object_name); CREATE INDEX scheduled_downtime_zone ON icinga_scheduled_downtime (zone_id);