From 9802f0066c9a892a73b6929af999205ff8d05825 Mon Sep 17 00:00:00 2001 From: jorgep Date: Mon, 29 Apr 2024 16:05:36 +0200 Subject: [PATCH] fix: refs #5919 unique key & unassigned locker --- db/routines/vn/procedures/workerDisable.sql | 4 ++++ db/versions/11019-grayDendro/00-locker.sql | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/db/routines/vn/procedures/workerDisable.sql b/db/routines/vn/procedures/workerDisable.sql index 4b10cb7fa..04612a6dc 100644 --- a/db/routines/vn/procedures/workerDisable.sql +++ b/db/routines/vn/procedures/workerDisable.sql @@ -28,5 +28,9 @@ mainLabel:BEGIN UPDATE `client` c SET c.salesPersonFk = null WHERE c.salesPersonFk = vUserId; + + UPDATE locker l + SET l.workerFk = NULL + WHERE l.workerFk = vUserId; END$$ DELIMITER ; diff --git a/db/versions/11019-grayDendro/00-locker.sql b/db/versions/11019-grayDendro/00-locker.sql index 462f56caa..2cb866b11 100644 --- a/db/versions/11019-grayDendro/00-locker.sql +++ b/db/versions/11019-grayDendro/00-locker.sql @@ -9,7 +9,7 @@ CREATE TABLE `vn`.`locker` ( `workerFk` int(10) unsigned DEFAULT NULL, PRIMARY KEY (`id`), UNIQUE KEY `code` (`code`), - KEY `workerFk` (`workerFk`), + UNIQUE KEY `workerFk` (`workerFk`), CONSTRAINT `locker_ibfk_1` FOREIGN KEY (`workerFk`) REFERENCES `worker` (`id`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci;