schema: add variable cache/lookup tables

refs #13068
This commit is contained in:
Thomas Gelf 2016-12-15 19:43:06 +01:00
parent e4525a09df
commit 07b6090c31
4 changed files with 668 additions and 6 deletions

View File

@ -0,0 +1,152 @@
ALTER TABLE icinga_command_var
ADD COLUMN checksum VARBINARY(20) DEFAULT NULL AFTER command_id,
ADD INDEX search_idx (varname),
ADD INDEX checksum (checksum);
ALTER TABLE icinga_host_var
ADD COLUMN checksum VARBINARY(20) DEFAULT NULL AFTER host_id,
ADD INDEX checksum (checksum);
ALTER TABLE icinga_notification_var
ADD COLUMN checksum VARBINARY(20) DEFAULT NULL AFTER notification_id,
ADD INDEX checksum (checksum);
ALTER TABLE icinga_service_set_var
ADD COLUMN checksum VARBINARY(20) DEFAULT NULL AFTER service_set_id,
ADD INDEX search_idx (varname),
ADD INDEX checksum (checksum);
ALTER TABLE icinga_service_var
ADD COLUMN checksum VARBINARY(20) DEFAULT NULL AFTER service_id,
ADD INDEX checksum (checksum);
ALTER TABLE icinga_user_var
ADD COLUMN checksum VARBINARY(20) DEFAULT NULL AFTER user_id,
ADD INDEX checksum (checksum);
CREATE TABLE icinga_var (
checksum VARBINARY(20) NOT NULL,
rendered_checksum VARBINARY(20) NOT NULL,
varname VARCHAR(255) NOT NULL COLLATE utf8_bin,
varvalue TEXT NOT NULL,
rendered TEXT NOT NULL,
PRIMARY KEY (checksum),
INDEX search_idx (varname)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
CREATE TABLE icinga_flat_var (
var_checksum VARBINARY(20) NOT NULL,
flatname_checksum VARBINARY(20) NOT NULL,
flatname VARCHAR(512) NOT NULL COLLATE utf8_bin,
flatvalue TEXT NOT NULL,
PRIMARY KEY (var_checksum, flatname_checksum),
INDEX search_varname (flatname),
INDEX search_varvalue (flatvalue (128)),
CONSTRAINT flat_var_var
FOREIGN KEY checksum (var_checksum)
REFERENCES icinga_var (checksum)
ON DELETE CASCADE
ON UPDATE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
CREATE TABLE icinga_command_resolved_var (
command_id INT(10) UNSIGNED NOT NULL,
varname VARCHAR(255) NOT NULL COLLATE utf8_bin,
checksum VARBINARY(20) NOT NULL,
PRIMARY KEY (command_id, checksum),
INDEX search_varname (varname),
CONSTRAINT command_resolved_var_command
FOREIGN KEY command (command_id)
REFERENCES icinga_command (id)
ON DELETE CASCADE
ON UPDATE CASCADE,
CONSTRAINT command_resolved_var_checksum
FOREIGN KEY checksum (checksum)
REFERENCES icinga_var (checksum)
ON DELETE RESTRICT
ON UPDATE RESTRICT
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
CREATE TABLE icinga_host_resolved_var (
host_id INT(10) UNSIGNED NOT NULL,
varname VARCHAR(255) NOT NULL COLLATE utf8_bin,
checksum VARBINARY(20) NOT NULL,
PRIMARY KEY (host_id, checksum),
INDEX search_varname (varname),
FOREIGN KEY host_resolved_var_host (host_id)
REFERENCES icinga_host (id)
ON DELETE CASCADE
ON UPDATE CASCADE,
FOREIGN KEY host_resolved_var_checksum (checksum)
REFERENCES icinga_var (checksum)
ON DELETE RESTRICT
ON UPDATE RESTRICT
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
CREATE TABLE icinga_notification_resolved_var (
notification_id INT(10) UNSIGNED NOT NULL,
varname VARCHAR(255) NOT NULL COLLATE utf8_bin,
checksum VARBINARY(20) NOT NULL,
PRIMARY KEY (notification_id, checksum),
INDEX search_varname (varname),
FOREIGN KEY notification_resolved_var_notification (notification_id)
REFERENCES icinga_notification (id)
ON DELETE CASCADE
ON UPDATE CASCADE,
FOREIGN KEY notification_resolved_var_checksum (checksum)
REFERENCES icinga_var (checksum)
ON DELETE RESTRICT
ON UPDATE RESTRICT
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
CREATE TABLE icinga_service_set_resolved_var (
service_set_id INT(10) UNSIGNED NOT NULL,
varname VARCHAR(255) NOT NULL COLLATE utf8_bin,
checksum VARBINARY(20) NOT NULL,
PRIMARY KEY (service_set_id, checksum),
INDEX search_varname (varname),
FOREIGN KEY service_set_resolved_var_service_set (service_set_id)
REFERENCES icinga_service_set (id)
ON DELETE CASCADE
ON UPDATE CASCADE,
FOREIGN KEY service_set_resolved_var_checksum(checksum)
REFERENCES icinga_var (checksum)
ON DELETE RESTRICT
ON UPDATE RESTRICT
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
CREATE TABLE icinga_service_resolved_var (
service_id INT(10) UNSIGNED NOT NULL,
varname VARCHAR(255) NOT NULL COLLATE utf8_bin,
checksum VARBINARY(20) NOT NULL,
PRIMARY KEY (service_id, checksum),
INDEX search_varname (varname),
FOREIGN KEY service_resolve_var_service (service_id)
REFERENCES icinga_service (id)
ON DELETE CASCADE
ON UPDATE CASCADE,
FOREIGN KEY service_resolve_var_checksum(checksum)
REFERENCES icinga_var (checksum)
ON DELETE RESTRICT
ON UPDATE RESTRICT
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
CREATE TABLE icinga_user_resolved_var (
user_id INT(10) UNSIGNED NOT NULL,
varname VARCHAR(255) NOT NULL COLLATE utf8_bin,
checksum VARBINARY(20) NOT NULL,
PRIMARY KEY (user_id, checksum),
INDEX search_varname (varname),
FOREIGN KEY user_resolve_var_user (user_id)
REFERENCES icinga_user (id)
ON DELETE CASCADE
ON UPDATE CASCADE,
FOREIGN KEY user_resolve_var_checksum(checksum)
REFERENCES icinga_var (checksum)
ON DELETE RESTRICT
ON UPDATE RESTRICT
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
INSERT INTO director_schema_migration
(schema_version, migration_time)
VALUES (127, NOW());

View File

@ -356,7 +356,10 @@ CREATE TABLE icinga_command_var (
varname VARCHAR(255) NOT NULL COLLATE utf8_bin, varname VARCHAR(255) NOT NULL COLLATE utf8_bin,
varvalue TEXT DEFAULT NULL, varvalue TEXT DEFAULT NULL,
format ENUM('string', 'expression', 'json') NOT NULL DEFAULT 'string', format ENUM('string', 'expression', 'json') NOT NULL DEFAULT 'string',
checksum VARBINARY(20) DEFAULT NULL,
PRIMARY KEY (command_id, varname), PRIMARY KEY (command_id, varname),
INDEX search_idx (varname),
INDEX checksum (checksum),
CONSTRAINT icinga_command_var_command CONSTRAINT icinga_command_var_command
FOREIGN KEY command (command_id) FOREIGN KEY command (command_id)
REFERENCES icinga_command (id) REFERENCES icinga_command (id)
@ -522,8 +525,10 @@ CREATE TABLE icinga_host_var (
varname VARCHAR(255) NOT NULL COLLATE utf8_bin, varname VARCHAR(255) NOT NULL COLLATE utf8_bin,
varvalue TEXT DEFAULT NULL, varvalue TEXT DEFAULT NULL,
format enum ('string', 'json', 'expression'), -- immer string vorerst format enum ('string', 'json', 'expression'), -- immer string vorerst
checksum VARBINARY(20) DEFAULT NULL,
PRIMARY KEY (host_id, varname), PRIMARY KEY (host_id, varname),
key search_idx (varname), INDEX search_idx (varname),
INDEX checksum (checksum),
CONSTRAINT icinga_host_var_host CONSTRAINT icinga_host_var_host
FOREIGN KEY host (host_id) FOREIGN KEY host (host_id)
REFERENCES icinga_host (id) REFERENCES icinga_host (id)
@ -642,8 +647,10 @@ CREATE TABLE icinga_service_var (
varname VARCHAR(255) NOT NULL COLLATE utf8_bin, varname VARCHAR(255) NOT NULL COLLATE utf8_bin,
varvalue TEXT DEFAULT NULL, varvalue TEXT DEFAULT NULL,
format enum ('string', 'json', 'expression'), format enum ('string', 'json', 'expression'),
checksum VARBINARY(20) DEFAULT NULL,
PRIMARY KEY (service_id, varname), PRIMARY KEY (service_id, varname),
key search_idx (varname), INDEX search_idx (varname),
INDEX checksum (checksum),
CONSTRAINT icinga_service_var_service CONSTRAINT icinga_service_var_service
FOREIGN KEY service (service_id) FOREIGN KEY service (service_id)
REFERENCES icinga_service (id) REFERENCES icinga_service (id)
@ -708,7 +715,10 @@ CREATE TABLE icinga_service_set_var (
varname VARCHAR(255) NOT NULL COLLATE utf8_bin, varname VARCHAR(255) NOT NULL COLLATE utf8_bin,
varvalue TEXT DEFAULT NULL, varvalue TEXT DEFAULT NULL,
format ENUM('string', 'expression', 'json') NOT NULL DEFAULT 'string', format ENUM('string', 'expression', 'json') NOT NULL DEFAULT 'string',
checksum VARBINARY(20) DEFAULT NULL,
PRIMARY KEY (service_set_id, varname), PRIMARY KEY (service_set_id, varname),
INDEX search_idx (varname),
INDEX checksum (checksum),
CONSTRAINT icinga_service_set_var_service CONSTRAINT icinga_service_set_var_service
FOREIGN KEY command (service_set_id) FOREIGN KEY command (service_set_id)
REFERENCES icinga_service_set (id) REFERENCES icinga_service_set (id)
@ -911,8 +921,10 @@ CREATE TABLE icinga_user_var (
varname VARCHAR(255) NOT NULL COLLATE utf8_bin, varname VARCHAR(255) NOT NULL COLLATE utf8_bin,
varvalue TEXT DEFAULT NULL, varvalue TEXT DEFAULT NULL,
format ENUM('string', 'json', 'expression') NOT NULL DEFAULT 'string', format ENUM('string', 'json', 'expression') NOT NULL DEFAULT 'string',
checksum VARBINARY(20) DEFAULT NULL,
PRIMARY KEY (user_id, varname), PRIMARY KEY (user_id, varname),
key search_idx (varname), INDEX search_idx (varname),
INDEX checksum (checksum),
CONSTRAINT icinga_user_var_user CONSTRAINT icinga_user_var_user
FOREIGN KEY icinga_user (user_id) FOREIGN KEY icinga_user (user_id)
REFERENCES icinga_user (id) REFERENCES icinga_user (id)
@ -1047,8 +1059,10 @@ CREATE TABLE icinga_notification_var (
varname VARCHAR(255) NOT NULL COLLATE utf8_bin, varname VARCHAR(255) NOT NULL COLLATE utf8_bin,
varvalue TEXT DEFAULT NULL, varvalue TEXT DEFAULT NULL,
format enum ('string', 'json', 'expression'), format enum ('string', 'json', 'expression'),
checksum VARBINARY(20) DEFAULT NULL,
PRIMARY KEY (notification_id, varname), PRIMARY KEY (notification_id, varname),
key search_idx (varname), INDEX search_idx (varname),
INDEX checksum (checksum),
CONSTRAINT icinga_notification_var_notification CONSTRAINT icinga_notification_var_notification
FOREIGN KEY notification (notification_id) FOREIGN KEY notification (notification_id)
REFERENCES icinga_notification (id) REFERENCES icinga_notification (id)
@ -1368,6 +1382,129 @@ CREATE TABLE sync_run (
ON UPDATE CASCADE ON UPDATE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8; ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
CREATE TABLE icinga_var (
checksum VARBINARY(20) NOT NULL,
rendered_checksum VARBINARY(20) NOT NULL,
varname VARCHAR(255) NOT NULL COLLATE utf8_bin,
varvalue TEXT NOT NULL,
rendered TEXT NOT NULL,
PRIMARY KEY (checksum),
INDEX search_idx (varname)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
CREATE TABLE icinga_flat_var (
var_checksum VARBINARY(20) NOT NULL,
flatname_checksum VARBINARY(20) NOT NULL,
flatname VARCHAR(512) NOT NULL COLLATE utf8_bin,
flatvalue TEXT NOT NULL,
PRIMARY KEY (var_checksum, flatname_checksum),
INDEX search_varname (flatname),
INDEX search_varvalue (flatvalue (128)),
CONSTRAINT flat_var_var
FOREIGN KEY checksum (var_checksum)
REFERENCES icinga_var (checksum)
ON DELETE CASCADE
ON UPDATE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
CREATE TABLE icinga_command_resolved_var (
command_id INT(10) UNSIGNED NOT NULL,
varname VARCHAR(255) NOT NULL COLLATE utf8_bin,
checksum VARBINARY(20) NOT NULL,
PRIMARY KEY (command_id, checksum),
INDEX search_varname (varname),
CONSTRAINT command_resolved_var_command
FOREIGN KEY command (command_id)
REFERENCES icinga_command (id)
ON DELETE CASCADE
ON UPDATE CASCADE,
CONSTRAINT command_resolved_var_checksum
FOREIGN KEY checksum (checksum)
REFERENCES icinga_var (checksum)
ON DELETE RESTRICT
ON UPDATE RESTRICT
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
CREATE TABLE icinga_host_resolved_var (
host_id INT(10) UNSIGNED NOT NULL,
varname VARCHAR(255) NOT NULL COLLATE utf8_bin,
checksum VARBINARY(20) NOT NULL,
PRIMARY KEY (host_id, checksum),
INDEX search_varname (varname),
FOREIGN KEY host_resolved_var_host (host_id)
REFERENCES icinga_host (id)
ON DELETE CASCADE
ON UPDATE CASCADE,
FOREIGN KEY host_resolved_var_checksum (checksum)
REFERENCES icinga_var (checksum)
ON DELETE RESTRICT
ON UPDATE RESTRICT
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
CREATE TABLE icinga_notification_resolved_var (
notification_id INT(10) UNSIGNED NOT NULL,
varname VARCHAR(255) NOT NULL COLLATE utf8_bin,
checksum VARBINARY(20) NOT NULL,
PRIMARY KEY (notification_id, checksum),
INDEX search_varname (varname),
FOREIGN KEY notification_resolved_var_notification (notification_id)
REFERENCES icinga_notification (id)
ON DELETE CASCADE
ON UPDATE CASCADE,
FOREIGN KEY notification_resolved_var_checksum (checksum)
REFERENCES icinga_var (checksum)
ON DELETE RESTRICT
ON UPDATE RESTRICT
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
CREATE TABLE icinga_service_set_resolved_var (
service_set_id INT(10) UNSIGNED NOT NULL,
varname VARCHAR(255) NOT NULL COLLATE utf8_bin,
checksum VARBINARY(20) NOT NULL,
PRIMARY KEY (service_set_id, checksum),
INDEX search_varname (varname),
FOREIGN KEY service_set_resolved_var_service_set (service_set_id)
REFERENCES icinga_service_set (id)
ON DELETE CASCADE
ON UPDATE CASCADE,
FOREIGN KEY service_set_resolved_var_checksum(checksum)
REFERENCES icinga_var (checksum)
ON DELETE RESTRICT
ON UPDATE RESTRICT
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
CREATE TABLE icinga_service_resolved_var (
service_id INT(10) UNSIGNED NOT NULL,
varname VARCHAR(255) NOT NULL COLLATE utf8_bin,
checksum VARBINARY(20) NOT NULL,
PRIMARY KEY (service_id, checksum),
INDEX search_varname (varname),
FOREIGN KEY service_resolve_var_service (service_id)
REFERENCES icinga_service (id)
ON DELETE CASCADE
ON UPDATE CASCADE,
FOREIGN KEY service_resolve_var_checksum(checksum)
REFERENCES icinga_var (checksum)
ON DELETE RESTRICT
ON UPDATE RESTRICT
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
CREATE TABLE icinga_user_resolved_var (
user_id INT(10) UNSIGNED NOT NULL,
varname VARCHAR(255) NOT NULL COLLATE utf8_bin,
checksum VARBINARY(20) NOT NULL,
PRIMARY KEY (user_id, checksum),
INDEX search_varname (varname),
FOREIGN KEY user_resolve_var_user (user_id)
REFERENCES icinga_user (id)
ON DELETE CASCADE
ON UPDATE CASCADE,
FOREIGN KEY user_resolve_var_checksum(checksum)
REFERENCES icinga_var (checksum)
ON DELETE RESTRICT
ON UPDATE RESTRICT
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
INSERT INTO director_schema_migration INSERT INTO director_schema_migration
(schema_version, migration_time) (schema_version, migration_time)
VALUES (126, NOW()); VALUES (127, NOW());

View File

@ -0,0 +1,197 @@
ALTER TABLE icinga_command_var
ADD COLUMN checksum bytea DEFAULT NULL CHECK(LENGTH(checksum) = 20);
CREATE INDEX command_var_search_idx ON icinga_command_var (varname);
CREATE INDEX command_var_checksum ON icinga_command_var (checksum);
ALTER TABLE icinga_host_var
ADD COLUMN checksum bytea DEFAULT NULL CHECK(LENGTH(checksum) = 20);
CREATE INDEX host_var_checksum ON icinga_host_var (checksum);
ALTER TABLE icinga_notification_var
ADD COLUMN checksum bytea DEFAULT NULL CHECK(LENGTH(checksum) = 20);
CREATE INDEX notification_var_command ON icinga_notification_var (notification_id);
CREATE INDEX notification_var_checksum ON icinga_notification_var (checksum);
ALTER TABLE icinga_service_set_var
ADD COLUMN checksum bytea DEFAULT NULL CHECK(LENGTH(checksum) = 20);
CREATE INDEX service_set_var_checksum ON icinga_service_set_var (checksum);
ALTER TABLE icinga_service_var
ADD COLUMN checksum bytea DEFAULT NULL CHECK(LENGTH(checksum) = 20);
CREATE INDEX service_var_checksum ON icinga_service_var (checksum);
ALTER TABLE icinga_user_var
ADD COLUMN checksum bytea DEFAULT NULL CHECK(LENGTH(checksum) = 20);
CREATE INDEX user_var_checksum ON icinga_user_var (checksum);
CREATE TABLE icinga_var (
checksum bytea NOT NULL CHECK(LENGTH(checksum) = 20),
rendered_checksum bytea NOT NULL CHECK(LENGTH(checksum) = 20),
varname character varying(255) NOT NULL,
varvalue TEXT NOT NULL,
rendered TEXT NOT NULL,
PRIMARY KEY (checksum)
);
CREATE INDEX var_search_idx ON icinga_var (varname);
CREATE TABLE icinga_flat_var (
var_checksum bytea NOT NULL CHECK(LENGTH(var_checksum) = 20),
flatname_checksum bytea NOT NULL CHECK(LENGTH(flatname_checksum) = 20),
flatname character varying(512) NOT NULL,
flatvalue TEXT NOT NULL,
PRIMARY KEY (var_checksum, flatname_checksum),
CONSTRAINT flat_var_var
FOREIGN KEY (var_checksum)
REFERENCES icinga_var (checksum)
ON DELETE CASCADE
ON UPDATE CASCADE
);
CREATE INDEX flat_var_var_checksum ON icinga_flat_var (var_checksum);
CREATE INDEX flat_var_search_varname ON icinga_flat_var (flatname);
CREATE INDEX flat_var_search_varvalue ON icinga_flat_var (flatvalue);
CREATE TABLE icinga_command_resolved_var (
command_id integer NOT NULL,
varname character varying(255) NOT NULL,
checksum bytea NOT NULL CHECK(LENGTH(checksum) = 20),
PRIMARY KEY (command_id, checksum),
CONSTRAINT command_resolved_var_command
FOREIGN KEY (command_id)
REFERENCES icinga_command (id)
ON DELETE CASCADE
ON UPDATE CASCADE,
CONSTRAINT command_resolved_var_checksum
FOREIGN KEY (checksum)
REFERENCES icinga_var (checksum)
ON DELETE RESTRICT
ON UPDATE RESTRICT
);
CREATE INDEX command_resolved_var_search_varname ON icinga_command_resolved_var (varname);
CREATE INDEX command_resolved_var_command_id ON icinga_command_resolved_var (command_id);
CREATE INDEX command_resolved_var_schecksum ON icinga_command_resolved_var (checksum);
CREATE TABLE icinga_host_resolved_var (
host_id integer NOT NULL,
varname character varying(255) NOT NULL,
checksum bytea NOT NULL CHECK(LENGTH(checksum) = 20),
PRIMARY KEY (host_id, checksum),
CONSTRAINT host_resolved_var_host
FOREIGN KEY (host_id)
REFERENCES icinga_host (id)
ON DELETE CASCADE
ON UPDATE CASCADE,
CONSTRAINT host_resolved_var_checksum
FOREIGN KEY (checksum)
REFERENCES icinga_var (checksum)
ON DELETE RESTRICT
ON UPDATE RESTRICT
);
CREATE INDEX host_resolved_var_search_varname ON icinga_host_resolved_var (varname);
CREATE INDEX host_resolved_var_host_id ON icinga_host_resolved_var (host_id);
CREATE INDEX host_resolved_var_schecksum ON icinga_host_resolved_var (checksum);
CREATE TABLE icinga_notification_resolved_var (
notification_id integer NOT NULL,
varname character varying(255) NOT NULL,
checksum bytea NOT NULL CHECK(LENGTH(checksum) = 20),
PRIMARY KEY (notification_id, checksum),
CONSTRAINT notification_resolved_var_notification
FOREIGN KEY (notification_id)
REFERENCES icinga_notification (id)
ON DELETE CASCADE
ON UPDATE CASCADE,
CONSTRAINT notification_resolved_var_checksum
FOREIGN KEY (checksum)
REFERENCES icinga_var (checksum)
ON DELETE RESTRICT
ON UPDATE RESTRICT
);
CREATE INDEX notification_resolved_var_search_varname ON icinga_notification_resolved_var (varname);
CREATE INDEX notification_resolved_var_notification_id ON icinga_notification_resolved_var (notification_id);
CREATE INDEX notification_resolved_var_schecksum ON icinga_notification_resolved_var (checksum);
CREATE TABLE icinga_service_set_resolved_var (
service_set_id integer NOT NULL,
varname character varying(255) NOT NULL,
checksum bytea NOT NULL CHECK(LENGTH(checksum) = 20),
PRIMARY KEY (service_set_id, checksum),
CONSTRAINT service_set_resolved_var_service_set
FOREIGN KEY (service_set_id)
REFERENCES icinga_service_set (id)
ON DELETE CASCADE
ON UPDATE CASCADE,
CONSTRAINT service_set_resolved_var_checksum
FOREIGN KEY (checksum)
REFERENCES icinga_var (checksum)
ON DELETE RESTRICT
ON UPDATE RESTRICT
);
CREATE INDEX service_set_resolved_var_search_varname ON icinga_service_set_resolved_var (varname);
CREATE INDEX service_set_resolved_var_service_set_id ON icinga_service_set_resolved_var (service_set_id);
CREATE INDEX service_set_resolved_var_schecksum ON icinga_service_set_resolved_var (checksum);
CREATE TABLE icinga_service_resolved_var (
service_id integer NOT NULL,
varname character varying(255) NOT NULL,
checksum bytea NOT NULL CHECK(LENGTH(checksum) = 20),
PRIMARY KEY (service_id, checksum),
CONSTRAINT service_resolved_var_service
FOREIGN KEY (service_id)
REFERENCES icinga_service (id)
ON DELETE CASCADE
ON UPDATE CASCADE,
CONSTRAINT service_resolved_var_checksum
FOREIGN KEY (checksum)
REFERENCES icinga_var (checksum)
ON DELETE RESTRICT
ON UPDATE RESTRICT
);
CREATE INDEX service_resolved_var_search_varname ON icinga_service_resolved_var (varname);
CREATE INDEX service_resolved_var_service_id ON icinga_service_resolved_var (service_id);
CREATE INDEX service_resolved_var_schecksum ON icinga_service_resolved_var (checksum);
CREATE TABLE icinga_user_resolved_var (
user_id integer NOT NULL,
varname character varying(255) NOT NULL,
checksum bytea NOT NULL CHECK(LENGTH(checksum) = 20),
PRIMARY KEY (user_id, checksum),
CONSTRAINT user_resolved_var_user
FOREIGN KEY (user_id)
REFERENCES icinga_user (id)
ON DELETE CASCADE
ON UPDATE CASCADE,
CONSTRAINT user_resolved_var_checksum
FOREIGN KEY (checksum)
REFERENCES icinga_var (checksum)
ON DELETE RESTRICT
ON UPDATE RESTRICT
);
CREATE INDEX user_resolved_var_search_varname ON icinga_user_resolved_var (varname);
CREATE INDEX user_resolved_var_user_id ON icinga_user_resolved_var (user_id);
CREATE INDEX user_resolved_var_schecksum ON icinga_user_resolved_var (checksum);
INSERT INTO director_schema_migration
(schema_version, migration_time)
VALUES (127, NOW());

View File

@ -460,6 +460,7 @@ CREATE TABLE icinga_command_field (
CREATE TABLE icinga_command_var ( CREATE TABLE icinga_command_var (
command_id integer NOT NULL, command_id integer NOT NULL,
checksum bytea DEFAULT NULL UNIQUE CHECK(LENGTH(checksum) = 20),
varname character varying(255) NOT NULL, varname character varying(255) NOT NULL,
varvalue text DEFAULT NULL, varvalue text DEFAULT NULL,
format enum_property_format NOT NULL DEFAULT 'string', format enum_property_format NOT NULL DEFAULT 'string',
@ -472,6 +473,8 @@ CREATE TABLE icinga_command_var (
); );
CREATE INDEX command_var_command ON icinga_command_var (command_id); CREATE INDEX command_var_command ON icinga_command_var (command_id);
CREATE INDEX command_var_search_idx ON icinga_command_var (varname);
CREATE INDEX command_var_checksum ON icinga_command_var (checksum);
CREATE TABLE icinga_apiuser ( CREATE TABLE icinga_apiuser (
@ -658,6 +661,7 @@ COMMENT ON COLUMN icinga_host_field.host_id IS 'Makes only sense for templates';
CREATE TABLE icinga_host_var ( CREATE TABLE icinga_host_var (
host_id integer NOT NULL, host_id integer NOT NULL,
checksum bytea DEFAULT NULL UNIQUE CHECK(LENGTH(checksum) = 20),
varname character varying(255) NOT NULL, varname character varying(255) NOT NULL,
varvalue text DEFAULT NULL, varvalue text DEFAULT NULL,
format enum_property_format, -- immer string vorerst format enum_property_format, -- immer string vorerst
@ -671,6 +675,7 @@ CREATE TABLE icinga_host_var (
CREATE INDEX host_var_search_idx ON icinga_host_var (varname); CREATE INDEX host_var_search_idx ON icinga_host_var (varname);
CREATE INDEX host_var_host ON icinga_host_var (host_id); CREATE INDEX host_var_host ON icinga_host_var (host_id);
CREATE INDEX host_var_checksum ON icinga_host_var (checksum);
CREATE TABLE icinga_service_set ( CREATE TABLE icinga_service_set (
@ -795,6 +800,7 @@ CREATE INDEX service_inheritance_service_parent ON icinga_service_inheritance (p
CREATE TABLE icinga_service_var ( CREATE TABLE icinga_service_var (
service_id integer NOT NULL, service_id integer NOT NULL,
checksum bytea DEFAULT NULL UNIQUE CHECK(LENGTH(checksum) = 20),
varname character varying(255) NOT NULL, varname character varying(255) NOT NULL,
varvalue text DEFAULT NULL, varvalue text DEFAULT NULL,
format enum_property_format, format enum_property_format,
@ -808,6 +814,7 @@ CREATE TABLE icinga_service_var (
CREATE INDEX service_var_search_idx ON icinga_service_var (varname); CREATE INDEX service_var_search_idx ON icinga_service_var (varname);
CREATE INDEX service_var_service ON icinga_service_var (service_id); CREATE INDEX service_var_service ON icinga_service_var (service_id);
CREATE INDEX service_var_checksum ON icinga_service_var (checksum);
CREATE TABLE icinga_service_field ( CREATE TABLE icinga_service_field (
@ -878,6 +885,7 @@ CREATE INDEX service_set_inheritance_parent ON icinga_service_set_inheritance (p
CREATE TABLE icinga_service_set_var ( CREATE TABLE icinga_service_set_var (
service_set_id integer NOT NULL, service_set_id integer NOT NULL,
checksum bytea DEFAULT NULL UNIQUE CHECK(LENGTH(checksum) = 20),
varname character varying(255) NOT NULL, varname character varying(255) NOT NULL,
varvalue text DEFAULT NULL, varvalue text DEFAULT NULL,
format enum_property_format NOT NULL DEFAULT 'string', format enum_property_format NOT NULL DEFAULT 'string',
@ -891,6 +899,7 @@ CREATE TABLE icinga_service_set_var (
CREATE INDEX service_set_var_service_set ON icinga_service_set_var (service_set_id); CREATE INDEX service_set_var_service_set ON icinga_service_set_var (service_set_id);
CREATE INDEX service_set_var_search_idx ON icinga_service_set_var (varname); CREATE INDEX service_set_var_search_idx ON icinga_service_set_var (varname);
CREATE INDEX service_set_var_checksum ON icinga_service_set_var (checksum);
CREATE TABLE icinga_hostgroup ( CREATE TABLE icinga_hostgroup (
@ -1105,6 +1114,7 @@ COMMENT ON COLUMN icinga_user_types_set.merge_behaviour IS 'override: = [], exte
CREATE TABLE icinga_user_var ( CREATE TABLE icinga_user_var (
user_id integer NOT NULL, user_id integer NOT NULL,
checksum bytea DEFAULT NULL UNIQUE CHECK(LENGTH(checksum) = 20),
varname character varying(255) NOT NULL, varname character varying(255) NOT NULL,
varvalue text DEFAULT NULL, varvalue text DEFAULT NULL,
format enum_property_format NOT NULL DEFAULT 'string', format enum_property_format NOT NULL DEFAULT 'string',
@ -1118,6 +1128,7 @@ CREATE TABLE icinga_user_var (
CREATE INDEX user_var_search_idx ON icinga_user_var (varname); CREATE INDEX user_var_search_idx ON icinga_user_var (varname);
CREATE INDEX user_var_user ON icinga_user_var (user_id); CREATE INDEX user_var_user ON icinga_user_var (user_id);
CREATE INDEX user_var_checksum ON icinga_user_var (checksum);
CREATE TABLE icinga_user_field ( CREATE TABLE icinga_user_field (
@ -1538,6 +1549,7 @@ COMMENT ON COLUMN icinga_notification_types_set.merge_behaviour IS 'override: =
CREATE TABLE icinga_notification_var ( CREATE TABLE icinga_notification_var (
notification_id integer NOT NULL, notification_id integer NOT NULL,
checksum bytea DEFAULT NULL UNIQUE CHECK(LENGTH(checksum) = 20),
varname VARCHAR(255) NOT NULL, varname VARCHAR(255) NOT NULL,
varvalue TEXT DEFAULT NULL, varvalue TEXT DEFAULT NULL,
format enum_property_format, format enum_property_format,
@ -1549,7 +1561,9 @@ CREATE TABLE icinga_notification_var (
ON UPDATE CASCADE ON UPDATE CASCADE
); );
CREATE INDEX notification_var_command ON icinga_notification_var (notification_id);
CREATE UNIQUE INDEX notification_var_search_idx ON icinga_notification_var (varname); CREATE UNIQUE INDEX notification_var_search_idx ON icinga_notification_var (varname);
CREATE INDEX notification_var_checksum ON icinga_notification_var (checksum);
CREATE TABLE icinga_notification_field ( CREATE TABLE icinga_notification_field (
@ -1596,6 +1610,168 @@ CREATE TABLE icinga_notification_inheritance (
CREATE UNIQUE INDEX notification_inheritance ON icinga_notification_inheritance (notification_id, weight); CREATE UNIQUE INDEX notification_inheritance ON icinga_notification_inheritance (notification_id, weight);
CREATE TABLE icinga_var (
checksum bytea NOT NULL CHECK(LENGTH(checksum) = 20),
rendered_checksum bytea NOT NULL CHECK(LENGTH(checksum) = 20),
varname character varying(255) NOT NULL,
varvalue TEXT NOT NULL,
rendered TEXT NOT NULL,
PRIMARY KEY (checksum)
);
CREATE INDEX var_search_idx ON icinga_var (varname);
CREATE TABLE icinga_flat_var (
var_checksum bytea NOT NULL CHECK(LENGTH(var_checksum) = 20),
flatname_checksum bytea NOT NULL CHECK(LENGTH(flatname_checksum) = 20),
flatname character varying(512) NOT NULL,
flatvalue TEXT NOT NULL,
PRIMARY KEY (var_checksum, flatname_checksum),
CONSTRAINT flat_var_var
FOREIGN KEY (var_checksum)
REFERENCES icinga_var (checksum)
ON DELETE CASCADE
ON UPDATE CASCADE
);
CREATE INDEX flat_var_var_checksum ON icinga_flat_var (var_checksum);
CREATE INDEX flat_var_search_varname ON icinga_flat_var (flatname);
CREATE INDEX flat_var_search_varvalue ON icinga_flat_var (flatvalue);
CREATE TABLE icinga_command_resolved_var (
command_id integer NOT NULL,
varname character varying(255) NOT NULL,
checksum bytea NOT NULL CHECK(LENGTH(checksum) = 20),
PRIMARY KEY (command_id, checksum),
CONSTRAINT command_resolved_var_command
FOREIGN KEY (command_id)
REFERENCES icinga_command (id)
ON DELETE CASCADE
ON UPDATE CASCADE,
CONSTRAINT command_resolved_var_checksum
FOREIGN KEY (checksum)
REFERENCES icinga_var (checksum)
ON DELETE RESTRICT
ON UPDATE RESTRICT
);
CREATE INDEX command_resolved_var_search_varname ON icinga_command_resolved_var (varname);
CREATE INDEX command_resolved_var_command_id ON icinga_command_resolved_var (command_id);
CREATE INDEX command_resolved_var_schecksum ON icinga_command_resolved_var (checksum);
CREATE TABLE icinga_host_resolved_var (
host_id integer NOT NULL,
varname character varying(255) NOT NULL,
checksum bytea NOT NULL CHECK(LENGTH(checksum) = 20),
PRIMARY KEY (host_id, checksum),
CONSTRAINT host_resolved_var_host
FOREIGN KEY (host_id)
REFERENCES icinga_host (id)
ON DELETE CASCADE
ON UPDATE CASCADE,
CONSTRAINT host_resolved_var_checksum
FOREIGN KEY (checksum)
REFERENCES icinga_var (checksum)
ON DELETE RESTRICT
ON UPDATE RESTRICT
);
CREATE INDEX host_resolved_var_search_varname ON icinga_host_resolved_var (varname);
CREATE INDEX host_resolved_var_host_id ON icinga_host_resolved_var (host_id);
CREATE INDEX host_resolved_var_schecksum ON icinga_host_resolved_var (checksum);
CREATE TABLE icinga_notification_resolved_var (
notification_id integer NOT NULL,
varname character varying(255) NOT NULL,
checksum bytea NOT NULL CHECK(LENGTH(checksum) = 20),
PRIMARY KEY (notification_id, checksum),
CONSTRAINT notification_resolved_var_notification
FOREIGN KEY (notification_id)
REFERENCES icinga_notification (id)
ON DELETE CASCADE
ON UPDATE CASCADE,
CONSTRAINT notification_resolved_var_checksum
FOREIGN KEY (checksum)
REFERENCES icinga_var (checksum)
ON DELETE RESTRICT
ON UPDATE RESTRICT
);
CREATE INDEX notification_resolved_var_search_varname ON icinga_notification_resolved_var (varname);
CREATE INDEX notification_resolved_var_notification_id ON icinga_notification_resolved_var (notification_id);
CREATE INDEX notification_resolved_var_schecksum ON icinga_notification_resolved_var (checksum);
CREATE TABLE icinga_service_set_resolved_var (
service_set_id integer NOT NULL,
varname character varying(255) NOT NULL,
checksum bytea NOT NULL CHECK(LENGTH(checksum) = 20),
PRIMARY KEY (service_set_id, checksum),
CONSTRAINT service_set_resolved_var_service_set
FOREIGN KEY (service_set_id)
REFERENCES icinga_service_set (id)
ON DELETE CASCADE
ON UPDATE CASCADE,
CONSTRAINT service_set_resolved_var_checksum
FOREIGN KEY (checksum)
REFERENCES icinga_var (checksum)
ON DELETE RESTRICT
ON UPDATE RESTRICT
);
CREATE INDEX service_set_resolved_var_search_varname ON icinga_service_set_resolved_var (varname);
CREATE INDEX service_set_resolved_var_service_set_id ON icinga_service_set_resolved_var (service_set_id);
CREATE INDEX service_set_resolved_var_schecksum ON icinga_service_set_resolved_var (checksum);
CREATE TABLE icinga_service_resolved_var (
service_id integer NOT NULL,
varname character varying(255) NOT NULL,
checksum bytea NOT NULL CHECK(LENGTH(checksum) = 20),
PRIMARY KEY (service_id, checksum),
CONSTRAINT service_resolved_var_service
FOREIGN KEY (service_id)
REFERENCES icinga_service (id)
ON DELETE CASCADE
ON UPDATE CASCADE,
CONSTRAINT service_resolved_var_checksum
FOREIGN KEY (checksum)
REFERENCES icinga_var (checksum)
ON DELETE RESTRICT
ON UPDATE RESTRICT
);
CREATE INDEX service_resolved_var_search_varname ON icinga_service_resolved_var (varname);
CREATE INDEX service_resolved_var_service_id ON icinga_service_resolved_var (service_id);
CREATE INDEX service_resolved_var_schecksum ON icinga_service_resolved_var (checksum);
CREATE TABLE icinga_user_resolved_var (
user_id integer NOT NULL,
varname character varying(255) NOT NULL,
checksum bytea NOT NULL CHECK(LENGTH(checksum) = 20),
PRIMARY KEY (user_id, checksum),
CONSTRAINT user_resolved_var_user
FOREIGN KEY (user_id)
REFERENCES icinga_user (id)
ON DELETE CASCADE
ON UPDATE CASCADE,
CONSTRAINT user_resolved_var_checksum
FOREIGN KEY (checksum)
REFERENCES icinga_var (checksum)
ON DELETE RESTRICT
ON UPDATE RESTRICT
);
CREATE INDEX user_resolved_var_search_varname ON icinga_user_resolved_var (varname);
CREATE INDEX user_resolved_var_user_id ON icinga_user_resolved_var (user_id);
CREATE INDEX user_resolved_var_schecksum ON icinga_user_resolved_var (checksum);
INSERT INTO director_schema_migration INSERT INTO director_schema_migration
(schema_version, migration_time) (schema_version, migration_time)
VALUES (125, NOW()); VALUES (127, NOW());