salix/db/changes/240201/00-locker.sql

36 lines
1.4 KiB
SQL

-- Eliminar locker
ALTER TABLE `vn`.`worker` DROP COLUMN `locker`;
CREATE TABLE `vn`.`locker` (
`id` int(100),
`code` varchar(10) DEFAULT NULL,
`gender` varchar(255) DEFAULT NULL,
`workerFk` int(10) unsigned DEFAULT NULL,
PRIMARY KEY (`code`),
UNIQUE KEY `code` (`code`),
KEY `workerFk` (`workerFk`),
CONSTRAINT `locker_ibfk_1` FOREIGN KEY (`workerFk`) REFERENCES `worker` (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci;
ALTER TABLE `vn`.`worker`
ADD CONSTRAINT `worker_locker_fk`
FOREIGN KEY (`locker`)
REFERENCES `vn`.`locker` (`code`)
ON UPDATE CASCADE
ON DELETE SET NULL;
-- Insertar taquillas disponibles para mujeres (1A - 73A / 1B - 73B)
INSERT INTO `vn`.`locker` (code, gender, workerFk) VALUES
('1A', 'M', NULL), ('2A', 'M', NULL), ('3A', 'M', NULL), ('4A', 'M', NULL), ('5A', 'M', NULL), ('6A', 'M', NULL), ('7A', 'M', NULL),
('1B', 'M', NULL), ('2B', 'M', NULL), ('3B', 'M', NULL), ('4B', 'M', NULL), ('5B', 'M', NULL), ('6B', 'M', NULL), ('7B', 'M', NULL);
-- Insertar taquillas disponibles para mujeres (200A - 217A / 200B - 217B)
INSERT INTO `vn`.`locker` (code, gender, workerFk) VALUES
('200A', 'F', NULL), ('201A', 'F', NULL), ('202A', 'F', NULL), ('203A', 'F', NULL), ('204A', 'F', NULL), ('205A', 'F', NULL), ('206A', 'F', NULL),
('200B', 'F', NULL), ('201B', 'F', NULL), ('202B', 'F', NULL), ('203B', 'F', NULL), ('204B', 'F', NULL), ('205B', 'F', NULL), ('206B', 'F', NULL);