From f2d4283304d50a3420c232ac987662392d46e872 Mon Sep 17 00:00:00 2001 From: pablone Date: Wed, 24 Apr 2024 14:29:57 +0200 Subject: [PATCH] fix: refs #7187 number on de code --- db/routines/vn/procedures/worker_checkMultipleDevice.sql | 6 ++++-- db/versions/11010-blackChrysanthemum/00-firstScript.sql | 3 +++ 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/db/routines/vn/procedures/worker_checkMultipleDevice.sql b/db/routines/vn/procedures/worker_checkMultipleDevice.sql index ecc485c9d..00df08d49 100644 --- a/db/routines/vn/procedures/worker_checkMultipleDevice.sql +++ b/db/routines/vn/procedures/worker_checkMultipleDevice.sql @@ -11,11 +11,13 @@ BEGIN */ DECLARE vHasPda BOOLEAN; DECLARE vIsFreelance BOOLEAN; + DECLARE vMaxDevicesPerUser INT; SELECT COUNT(*) INTO vHasPda FROM deviceProductionUser WHERE userFk = vSelf; - SELECT isFreelance INTO vIsFreelance FROM worker WHERE id = vSelf; + SELECT IFNULL(isFreelance, FALSE) INTO vIsFreelance FROM worker WHERE id = vSelf; + SELECT IFNULL(maxDevicesPerUser, FALSE) INTO vMaxDevicesPerUser FROM deviceProductionConfig LIMIT 1; - IF NOT vIsFreelance AND vHasPda > 1 THEN + IF NOT vIsFreelance AND vHasPda > vMaxDevicesPerUser THEN CALL util.throw('You can only have one PDA'); END IF; END$$ diff --git a/db/versions/11010-blackChrysanthemum/00-firstScript.sql b/db/versions/11010-blackChrysanthemum/00-firstScript.sql index c274d1c71..556ddfc1b 100644 --- a/db/versions/11010-blackChrysanthemum/00-firstScript.sql +++ b/db/versions/11010-blackChrysanthemum/00-firstScript.sql @@ -12,3 +12,6 @@ ALTER TABLE vn.deviceProductionUser ADD CONSTRAINT deviceProductionUser_unique U ALTER TABLE vn.deviceProduction ADD simSerialNumber TEXT NULL; +ALTER TABLE vn.deviceProductionConfig ADD maxDevicesPerUser INT UNSIGNED NULL; + +UPDATE vn.deviceProductionConfig SET maxDevicesPerUser=1 WHERE id=1;