schema: add postgresql, add migration number

This commit is contained in:
Thomas Gelf 2019-10-02 09:53:15 +02:00
parent 633f4802f0
commit 9f7efeeb61
5 changed files with 72 additions and 19 deletions

View File

@ -0,0 +1,21 @@
CREATE TABLE director_datafield_category (
id INT(10) UNSIGNED NOT NULL AUTO_INCREMENT,
category_name VARCHAR(255) NOT NULL,
description TEXT DEFAULT NULL,
PRIMARY KEY (id),
UNIQUE KEY category_name (category_name)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
ALTER TABLE director_datafield
ADD COLUMN category_id INT(10) UNSIGNED DEFAULT NULL AFTER id,
ADD CONSTRAINT director_datafield_category
FOREIGN KEY category (category_id)
REFERENCES director_datafield_category (id)
ON DELETE RESTRICT
ON UPDATE CASCADE
;
INSERT INTO director_schema_migration
(schema_version, migration_time)
VALUES (168, NOW());

View File

@ -1,15 +0,0 @@
CREATE TABLE director_datafield_category (
id INT(10) UNSIGNED NOT NULL AUTO_INCREMENT,
category_name VARCHAR(255) NOT NULL,
description TEXT DEFAULT NULL,
PRIMARY KEY (id),
UNIQUE KEY category_name (category_name)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
ALTER TABLE director_datafield
ADD COLUMN category_id INT(10) UNSIGNED DEFAULT NULL AFTER id;
-- INSERT INTO director_schema_migration
-- (schema_version, migration_time)
-- VALUES (167, NOW());

View File

@ -197,7 +197,12 @@ CREATE TABLE director_datafield (
-- datatype_param? multiple ones?
format enum ('string', 'json', 'expression'),
PRIMARY KEY (id),
KEY search_idx (varname)
KEY search_idx (varname),
CONSTRAINT director_datalist_value_datalist
FOREIGN KEY category (category_id)
REFERENCES director_datafield_category (id)
ON DELETE RESTRICT
ON UPDATE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
CREATE TABLE director_datafield_setting (
@ -1878,4 +1883,4 @@ CREATE TABLE icinga_scheduled_downtime_range (
INSERT INTO director_schema_migration
(schema_version, migration_time)
VALUES (167, NOW());
VALUES (168, NOW());

View File

@ -0,0 +1,25 @@
CREATE TABLE director_datafield_category (
id serial,
category_name character varying(255) NOT NULL,
description text DEFAULT NULL,
PRIMARY KEY (id)
);
CREATE UNIQUE INDEX datafield_category_name ON director_datafield_category (category_name);
ALTER TABLE director_datafield
ADD COLUMN category_id integer DEFAULT NULL,
ADD CONSTRAINT director_datafield_category
FOREIGN KEY (category_id)
REFERENCES director_datafield_category (id)
ON DELETE RESTRICT
ON UPDATE CASCADE;
CREATE INDEX datafield_category ON director_datafield (category_id);
INSERT INTO director_schema_migration
(schema_version, migration_time)
VALUES (168, NOW());

View File

@ -248,18 +248,35 @@ CREATE TABLE director_datalist_entry (
CREATE INDEX datalist_entry_datalist ON director_datalist_entry (list_id);
CREATE TABLE director_datafield_category (
id serial,
category_name character varying(255) NOT NULL,
description text DEFAULT NULL,
PRIMARY KEY (id)
);
CREATE UNIQUE INDEX datafield_category_name ON director_datafield_category (category_name);
CREATE TABLE director_datafield (
id serial,
category_id integer DEFAULT NULL,
varname character varying(64) NOT NULL,
caption character varying(255) NOT NULL,
description text DEFAULT NULL,
datatype character varying(255) NOT NULL,
-- datatype_param? multiple ones?
format enum_property_format,
PRIMARY KEY (id)
PRIMARY KEY (id),
CONSTRAINT director_datafield_category
FOREIGN KEY (category_id)
REFERENCES director_datafield_category (id)
ON DELETE RESTRICT
ON UPDATE CASCADE
);
CREATE INDEX search_idx ON director_datafield (varname);
CREATE INDEX datafield_category ON director_datafield (category_id);
CREATE TABLE director_datafield_setting (
@ -2182,4 +2199,4 @@ COMMENT ON COLUMN icinga_scheduled_downtime_range.merge_behaviour IS 'set -> = {
INSERT INTO director_schema_migration
(schema_version, migration_time)
VALUES (167, NOW());
VALUES (168, NOW());