schema: migrations for range properties

This commit is contained in:
Thomas Gelf 2016-08-31 16:24:40 +00:00
parent 029907f01f
commit 13ed701436
4 changed files with 46 additions and 8 deletions

View File

@ -0,0 +1,19 @@
ALTER TABLE icinga_timeperiod_range
ADD COLUMN range_key VARCHAR(255) NOT NULL COMMENT 'monday, ...',
ADD COLUMN range_value VARCHAR(255) NOT NULL COMMENT '00:00-24:00, ...';
UPDATE icinga_timeperiod_range
SET range_key = timeperiod_key,
range_value = timeperiod_value;
ALTER TABLE icinga_timeperiod_range
DROP PRIMARY KEY,
ADD PRIMARY KEY (timeperiod_id, range_type, range_key);
ALTER TABLE icinga_timeperiod_range
DROP COLUMN timeperiod_key,
DROP COLUMN timeperiod_value;
INSERT INTO director_schema_migration
(schema_version, migration_time)
VALUES (104, NOW());

View File

@ -223,13 +223,13 @@ CREATE TABLE icinga_timeperiod_inheritance (
CREATE TABLE icinga_timeperiod_range (
timeperiod_id INT(10) UNSIGNED AUTO_INCREMENT NOT NULL,
timeperiod_key VARCHAR(255) NOT NULL COMMENT 'monday, ...',
timeperiod_value VARCHAR(255) NOT NULL COMMENT '00:00-24:00, ...',
range_key VARCHAR(255) NOT NULL COMMENT 'monday, ...',
range_value VARCHAR(255) NOT NULL COMMENT '00:00-24:00, ...',
range_type ENUM('include', 'exclude') NOT NULL DEFAULT 'include'
COMMENT 'include -> ranges {}, exclude ranges_ignore {} - not yet',
merge_behaviour ENUM('set', 'add', 'substract') NOT NULL DEFAULT 'set'
COMMENT 'set -> = {}, add -> += {}, substract -> -= {}',
PRIMARY KEY (timeperiod_id, range_type, timeperiod_key),
PRIMARY KEY (timeperiod_id, range_type, range_key),
CONSTRAINT icinga_timeperiod_range_timeperiod
FOREIGN KEY timeperiod (timeperiod_id)
REFERENCES icinga_timeperiod (id)
@ -1312,4 +1312,4 @@ CREATE TABLE sync_run (
INSERT INTO director_schema_migration
SET migration_time = NOW(),
schema_version = 103;
schema_version = 104;

View File

@ -0,0 +1,19 @@
ALTER TABLE icinga_timeperiod_range
ADD COLUMN range_key character varying(255) NOT NULL,
ADD COLUMN range_value character varying(255) NOT NULL;
UPDATE icinga_timeperiod_range
SET range_key = timeperiod_key,
range_value = timeperiod_value;
ALTER TABLE icinga_timeperiod_range
DROP CONSTRAINT icinga_timeperiod_range_pkey,
ADD PRIMARY KEY (timeperiod_id, range_type, range_key);
ALTER TABLE icinga_timeperiod_range
DROP COLUMN timeperiod_key,
DROP COLUMN timeperiod_value;
INSERT INTO director_schema_migration
(schema_version, migration_time)
VALUES (104, NOW());

View File

@ -312,11 +312,11 @@ CREATE INDEX timeperiod_inheritance_timeperiod_parent ON icinga_timeperiod_inher
CREATE TABLE icinga_timeperiod_range (
timeperiod_id serial,
timeperiod_key character varying(255) NOT NULL,
timeperiod_value character varying(255) NOT NULL,
range_key character varying(255) NOT NULL,
range_value character varying(255) NOT NULL,
range_type enum_timeperiod_range_type NOT NULL DEFAULT 'include',
merge_behaviour enum_merge_behaviour NOT NULL DEFAULT 'set',
PRIMARY KEY (timeperiod_id, range_type, timeperiod_key),
PRIMARY KEY (timeperiod_id, range_type, range_key),
CONSTRAINT icinga_timeperiod_range_timeperiod
FOREIGN KEY (timeperiod_id)
REFERENCES icinga_timeperiod (id)
@ -1532,4 +1532,4 @@ CREATE UNIQUE INDEX notification_inheritance ON icinga_notification_inheritance
INSERT INTO director_schema_migration
(schema_version, migration_time)
VALUES (103, NOW());
VALUES (104, NOW());