diff --git a/schema/mysql-changes/upgrade_22.sql b/schema/mysql-changes/upgrade_22.sql new file mode 100644 index 00000000..418145c9 --- /dev/null +++ b/schema/mysql-changes/upgrade_22.sql @@ -0,0 +1,43 @@ +CREATE TABLE icinga_host_field ( + host_id INT(10) UNSIGNED NOT NULL COMMENT 'Makes only sense for templates', + fieldname VARCHAR(64) NOT NULL, + caption VARCHAR(255) NOT NULL, + datatype_id INT(10) UNSIGNED NOT NULL, +-- datatype_param? multiple ones? + default_value TEXT DEFAULT NULL, + format enum ('string', 'json', 'expression'), + PRIMARY KEY (host_id, fieldname), + KEY search_idx (fieldname), + CONSTRAINT icinga_host_field_host + FOREIGN KEY host(host_id) + REFERENCES icinga_host (id) + ON DELETE CASCADE + ON UPDATE CASCADE, + CONSTRAINT icinga_host_field_datatype + FOREIGN KEY datatype (datatype_id) + REFERENCES director_datatype (id) + ON DELETE RESTRICT + ON UPDATE CASCADE +) ENGINE=InnoDB DEFAULT CHARSET=utf8; + +CREATE TABLE icinga_service_field ( + service_id INT(10) UNSIGNED NOT NULL COMMENT 'Makes only sense for templates', + fieldname VARCHAR(64) NOT NULL, + caption VARCHAR(255) NOT NULL, + datatype_id INT(10) UNSIGNED NOT NULL, + -- datatype_param? multiple ones? + default_value TEXT DEFAULT NULL, + format enum ('string', 'json', 'expression'), + PRIMARY KEY (service_id, fieldname), + KEY search_idx (fieldname), + CONSTRAINT icinga_service_field_service + FOREIGN KEY service (service_id) + REFERENCES icinga_service (id) + ON DELETE CASCADE + ON UPDATE CASCADE, + CONSTRAINT icinga_service_field_datatype + FOREIGN KEY datatype (datatype_id) + REFERENCES director_datatype (id) + ON DELETE RESTRICT + ON UPDATE CASCADE +) ENGINE=InnoDB DEFAULT CHARSET=utf8; diff --git a/schema/mysql.sql b/schema/mysql.sql index ad7569f7..24ed114d 100644 --- a/schema/mysql.sql +++ b/schema/mysql.sql @@ -116,7 +116,7 @@ CREATE TABLE director_datalist_entry ( CREATE TABLE director_datatype ( id INT(10) UNSIGNED AUTO_INCREMENT NOT NULL, datatype_name VARCHAR(255) NOT NULL, - -- ?? expression VARCHAR(255) NOT NULL, + datatype_class VARCHAR(255) NOT NULL, PRIMARY KEY (id), UNIQUE KEY datatype_name (datatype_name) ) ENGINE=InnoDB DEFAULT CHARSET=utf8; @@ -387,6 +387,28 @@ CREATE TABLE icinga_host_inheritance ( ON UPDATE CASCADE ) ENGINE=InnoDB DEFAULT CHARSET=utf8; +CREATE TABLE icinga_host_field ( + host_id INT(10) UNSIGNED NOT NULL COMMENT 'Makes only sense for templates', + fieldname VARCHAR(64) NOT NULL, + caption VARCHAR(255) NOT NULL, + datatype_id INT(10) UNSIGNED NOT NULL, +-- datatype_param? multiple ones? + default_value TEXT DEFAULT NULL, + format enum ('string', 'json', 'expression'), + PRIMARY KEY (host_id, fieldname), + KEY search_idx (fieldname), + CONSTRAINT icinga_host_field_host + FOREIGN KEY host(host_id) + REFERENCES icinga_host (id) + ON DELETE CASCADE + ON UPDATE CASCADE, + CONSTRAINT icinga_host_field_datatype + FOREIGN KEY datatype (datatype_id) + REFERENCES director_datatype (id) + ON DELETE RESTRICT + ON UPDATE CASCADE +) ENGINE=InnoDB DEFAULT CHARSET=utf8; + CREATE TABLE icinga_host_var ( host_id INT(10) UNSIGNED NOT NULL, varname VARCHAR(255) DEFAULT NULL, @@ -488,6 +510,28 @@ CREATE TABLE icinga_service_var ( ON UPDATE CASCADE ) ENGINE=InnoDB DEFAULT CHARSET=utf8; +CREATE TABLE icinga_service_field ( + service_id INT(10) UNSIGNED NOT NULL COMMENT 'Makes only sense for templates', + fieldname VARCHAR(64) NOT NULL, + caption VARCHAR(255) NOT NULL, + datatype_id INT(10) UNSIGNED NOT NULL, + -- datatype_param? multiple ones? + default_value TEXT DEFAULT NULL, + format enum ('string', 'json', 'expression'), + PRIMARY KEY (service_id, fieldname), + KEY search_idx (fieldname), + CONSTRAINT icinga_service_field_service + FOREIGN KEY service (service_id) + REFERENCES icinga_service (id) + ON DELETE CASCADE + ON UPDATE CASCADE, + CONSTRAINT icinga_service_field_datatype + FOREIGN KEY datatype (datatype_id) + REFERENCES director_datatype (id) + ON DELETE RESTRICT + ON UPDATE CASCADE +) ENGINE=InnoDB DEFAULT CHARSET=utf8; + CREATE TABLE icinga_host_service ( host_id INT(10) UNSIGNED NOT NULL, service_id INT(10) UNSIGNED NOT NULL, diff --git a/schema/pgsql-changes/upgrade_22.sql b/schema/pgsql-changes/upgrade_22.sql new file mode 100644 index 00000000..6106f145 --- /dev/null +++ b/schema/pgsql-changes/upgrade_22.sql @@ -0,0 +1,52 @@ +CREATE TABLE icinga_host_field ( + host_id integer NOT NULL, + fieldname character varying(64) NOT NULL, + caption character varying(255) NOT NULL, + datatype_id integer NOT NULL, +-- datatype_param? multiple ones? + default_value text DEFAULT NULL, + format enum_property_format, + PRIMARY KEY (host_id, fieldname), + CONSTRAINT icinga_host_field_host + FOREIGN KEY (host_id) + REFERENCES icinga_host (id) + ON DELETE CASCADE + ON UPDATE CASCADE, + CONSTRAINT icinga_host_field_datatype + FOREIGN KEY datatype (datatype_id) + REFERENCES director_datatype (id) + ON DELETE RESTRICT + ON UPDATE CASCADE +); + +CREATE UNIQUE INDEX host_field_key ON icinga_host_field (host_id, fieldname); +CREATE INDEX host_field_search_idx ON icinga_host_field (fieldname); +CREATE INDEX host_field_host ON icinga_host_field (host_id); +COMMENT ON COLUMN icinga_host_field.host_id IS 'Makes only sense for templates'; + + +CREATE TABLE icinga_service_field ( + service_id integer NOT NULL, + fieldname character varying(64) NOT NULL, + caption character varying(255) NOT NULL, + datatype_id integer NOT NULL, +-- datatype_param? multiple ones? + default_value text DEFAULT NULL, + format enum_property_format, + PRIMARY KEY (service_id, fieldname), + CONSTRAINT icinga_service_field_service + FOREIGN KEY (service_id) + REFERENCES icinga_service (id) + ON DELETE CASCADE + ON UPDATE CASCADE, + CONSTRAINT icinga_service_field_datatype + FOREIGN KEY datatype (datatype_id) + REFERENCES director_datatype (id) + ON DELETE RESTRICT + ON UPDATE CASCADE +); + +CREATE UNIQUE INDEX service_field_key ON icinga_service_field (service_id, fieldname); +CREATE INDEX service_field_search_idx ON icinga_service_field (fieldname); +CREATE INDEX service_field_service ON icinga_service_field (service_id); +COMMENT ON COLUMN icinga_service_field.service_id IS 'Makes only sense for templates'; diff --git a/schema/pgsql.sql b/schema/pgsql.sql index 6ba9ad16..a442e9a2 100644 --- a/schema/pgsql.sql +++ b/schema/pgsql.sql @@ -482,6 +482,33 @@ CREATE INDEX host_inheritance_host ON icinga_host_inheritance (host_id); CREATE INDEX host_inheritance_host_parent ON icinga_host_inheritance (parent_host_id); +CREATE TABLE icinga_host_field ( + host_id integer NOT NULL, + fieldname character varying(64) NOT NULL, + caption character varying(255) NOT NULL, + datatype_id integer NOT NULL, +-- datatype_param? multiple ones? + default_value text DEFAULT NULL, + format enum_property_format, + PRIMARY KEY (host_id, fieldname), + CONSTRAINT icinga_host_field_host + FOREIGN KEY (host_id) + REFERENCES icinga_host (id) + ON DELETE CASCADE + ON UPDATE CASCADE, + CONSTRAINT icinga_host_field_datatype + FOREIGN KEY datatype (datatype_id) + REFERENCES director_datatype (id) + ON DELETE RESTRICT + ON UPDATE CASCADE +); + +CREATE UNIQUE INDEX host_field_key ON icinga_host_field (host_id, fieldname); +CREATE INDEX host_field_search_idx ON icinga_host_field (fieldname); +CREATE INDEX host_field_host ON icinga_host_field (host_id); +COMMENT ON COLUMN icinga_host_field.host_id IS 'Makes only sense for templates'; + + CREATE TABLE icinga_host_var ( host_id integer NOT NULL, varname character varying(255) DEFAULT NULL, @@ -583,6 +610,33 @@ CREATE INDEX service_inheritance_service ON icinga_service_inheritance (service_ CREATE INDEX service_inheritance_service_parent ON icinga_service_inheritance (parent_service_id); +CREATE TABLE icinga_service_field ( + service_id integer NOT NULL, + fieldname character varying(64) NOT NULL, + caption character varying(255) NOT NULL, + datatype_id integer NOT NULL, +-- datatype_param? multiple ones? + default_value text DEFAULT NULL, + format enum_property_format, + PRIMARY KEY (service_id, fieldname), + CONSTRAINT icinga_service_field_service + FOREIGN KEY (service_id) + REFERENCES icinga_service (id) + ON DELETE CASCADE + ON UPDATE CASCADE, + CONSTRAINT icinga_service_field_datatype + FOREIGN KEY datatype (datatype_id) + REFERENCES director_datatype (id) + ON DELETE RESTRICT + ON UPDATE CASCADE +); + +CREATE UNIQUE INDEX service_field_key ON icinga_service_field (service_id, fieldname); +CREATE INDEX service_field_search_idx ON icinga_service_field (fieldname); +CREATE INDEX service_field_service ON icinga_service_field (service_id); +COMMENT ON COLUMN icinga_service_field.service_id IS 'Makes only sense for templates'; + + CREATE TABLE icinga_service_var ( service_id integer NOT NULL, varname character varying(255) DEFAULT NULL,