schema/150: Add constraint from user to period
This commit is contained in:
parent
fbef8866ce
commit
4df7e8a23f
|
@ -0,0 +1,17 @@
|
||||||
|
UPDATE icinga_user u
|
||||||
|
SET period_id = NULL
|
||||||
|
WHERE NOT EXISTS (
|
||||||
|
SELECT id FROM icinga_timeperiod
|
||||||
|
WHERE id = u.period_id
|
||||||
|
) AND u.period_id IS NOT NULL;
|
||||||
|
|
||||||
|
ALTER TABLE icinga_user
|
||||||
|
ADD CONSTRAINT icinga_user_period
|
||||||
|
FOREIGN KEY period (period_id)
|
||||||
|
REFERENCES icinga_timeperiod (id)
|
||||||
|
ON DELETE RESTRICT
|
||||||
|
ON UPDATE CASCADE;
|
||||||
|
|
||||||
|
INSERT INTO director_schema_migration
|
||||||
|
(schema_version, migration_time)
|
||||||
|
VALUES (150, NOW());
|
|
@ -940,6 +940,11 @@ CREATE TABLE icinga_user (
|
||||||
FOREIGN KEY zone (zone_id)
|
FOREIGN KEY zone (zone_id)
|
||||||
REFERENCES icinga_zone (id)
|
REFERENCES icinga_zone (id)
|
||||||
ON DELETE RESTRICT
|
ON DELETE RESTRICT
|
||||||
|
ON UPDATE CASCADE,
|
||||||
|
CONSTRAINT icinga_user_period
|
||||||
|
FOREIGN KEY period (period_id)
|
||||||
|
REFERENCES icinga_timeperiod (id)
|
||||||
|
ON DELETE RESTRICT
|
||||||
ON UPDATE CASCADE
|
ON UPDATE CASCADE
|
||||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
|
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
|
||||||
|
|
||||||
|
@ -1692,4 +1697,4 @@ CREATE TABLE icinga_dependency_states_set (
|
||||||
|
|
||||||
INSERT INTO director_schema_migration
|
INSERT INTO director_schema_migration
|
||||||
(schema_version, migration_time)
|
(schema_version, migration_time)
|
||||||
VALUES (149, NOW());
|
VALUES (150, NOW());
|
||||||
|
|
|
@ -0,0 +1,17 @@
|
||||||
|
UPDATE icinga_user u
|
||||||
|
SET period_id = NULL
|
||||||
|
WHERE NOT EXISTS (
|
||||||
|
SELECT id FROM icinga_timeperiod
|
||||||
|
WHERE id = u.period_id
|
||||||
|
) AND u.period_id IS NOT NULL;
|
||||||
|
|
||||||
|
ALTER TABLE icinga_user
|
||||||
|
ADD CONSTRAINT icinga_user_period
|
||||||
|
FOREIGN KEY (period_id)
|
||||||
|
REFERENCES icinga_timeperiod (id)
|
||||||
|
ON DELETE RESTRICT
|
||||||
|
ON UPDATE CASCADE;
|
||||||
|
|
||||||
|
INSERT INTO director_schema_migration
|
||||||
|
(schema_version, migration_time)
|
||||||
|
VALUES (150, NOW());
|
|
@ -1157,6 +1157,11 @@ CREATE TABLE icinga_user (
|
||||||
FOREIGN KEY (zone_id)
|
FOREIGN KEY (zone_id)
|
||||||
REFERENCES icinga_zone (id)
|
REFERENCES icinga_zone (id)
|
||||||
ON DELETE RESTRICT
|
ON DELETE RESTRICT
|
||||||
|
ON UPDATE CASCADE,
|
||||||
|
CONSTRAINT icinga_user_period
|
||||||
|
FOREIGN KEY (period_id)
|
||||||
|
REFERENCES icinga_timeperiod (id)
|
||||||
|
ON DELETE RESTRICT
|
||||||
ON UPDATE CASCADE
|
ON UPDATE CASCADE
|
||||||
);
|
);
|
||||||
|
|
||||||
|
@ -1988,4 +1993,4 @@ COMMENT ON COLUMN icinga_dependency_states_set.merge_behaviour IS 'override: = [
|
||||||
|
|
||||||
INSERT INTO director_schema_migration
|
INSERT INTO director_schema_migration
|
||||||
(schema_version, migration_time)
|
(schema_version, migration_time)
|
||||||
VALUES (149, NOW());
|
VALUES (150, NOW());
|
||||||
|
|
Loading…
Reference in New Issue