fix: refs #7187 number on de code
gitea/salix/pipeline/pr-dev This commit looks good Details

This commit is contained in:
Pablo Natek 2024-04-24 14:29:57 +02:00
parent e8a32d8e13
commit f2d4283304
2 changed files with 7 additions and 2 deletions

View File

@ -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$$

View File

@ -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;