Revert "schema/150: Add constraint from user to period"

This reverts commit 4b9ab649af.

Ooops: ERROR: Icinga\Exception\IcingaException in /workdir/icingaweb2-modules/director/library/Director/Db/Migration.php:50 with message: Migration 150 failed (SQLSTATE[HY000]: General error: 1093 Table 'icinga_user' is specified twice, both as a target for 'UPDATE' and as a separate source for data) while running UPDATE icinga_user
SET period_id = NULL
WHERE id IN (
  SELECT DISTINCT u.id
  FROM icinga_user u
  LEFT JOIN icinga_timeperiod tp ON tp.id = u.period_id
  WHERE u.period_id IS NOT NULL AND tp.id IS NULL
);
This commit is contained in:
Thomas Gelf 2018-09-05 18:32:52 +02:00
parent 4b9ab649af
commit fbef8866ce
4 changed files with 2 additions and 50 deletions

View File

@ -1,19 +0,0 @@
UPDATE icinga_user
SET period_id = NULL
WHERE id IN (
SELECT DISTINCT u.id
FROM icinga_user u
LEFT JOIN icinga_timeperiod tp ON tp.id = u.period_id
WHERE u.period_id IS NOT NULL AND tp.id IS 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());

View File

@ -940,11 +940,6 @@ CREATE TABLE icinga_user (
FOREIGN KEY zone (zone_id)
REFERENCES icinga_zone (id)
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
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
@ -1697,4 +1692,4 @@ CREATE TABLE icinga_dependency_states_set (
INSERT INTO director_schema_migration
(schema_version, migration_time)
VALUES (150, NOW());
VALUES (149, NOW());

View File

@ -1,19 +0,0 @@
UPDATE icinga_user
SET period_id = NULL
WHERE id IN (
SELECT DISTINCT u.id
FROM icinga_user u
LEFT JOIN icinga_timeperiod tp ON tp.id = u.period_id
WHERE u.period_id IS NOT NULL AND tp.id IS 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());

View File

@ -1157,11 +1157,6 @@ CREATE TABLE icinga_user (
FOREIGN KEY (zone_id)
REFERENCES icinga_zone (id)
ON DELETE RESTRICT
ON UPDATE CASCADE,
CONSTRAINT icinga_user_period
FOREIGN KEY (period_id)
REFERENCES icinga_timeperiod (id)
ON DELETE RESTRICT
ON UPDATE CASCADE
);
@ -1993,4 +1988,4 @@ COMMENT ON COLUMN icinga_dependency_states_set.merge_behaviour IS 'override: = [
INSERT INTO director_schema_migration
(schema_version, migration_time)
VALUES (150, NOW());
VALUES (149, NOW());