salix/db/versions/11149-silverSalal/00-firstScript.sql

28 lines
1.4 KiB
MySQL
Raw Normal View History

2024-07-11 06:57:45 +00:00
ALTER TABLE vn.item CHANGE minQuantity minQuantity__ int(10) unsigned DEFAULT
NULL NULL COMMENT '@deprecated 2024-07-11 refs #7704 Cantidad mínima para una línea de venta';
CREATE TABLE `vn`.`itemMinimumQuantity` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`itemFk` int(10) NOT NULL,
`quantity` int(10) NOT NULL,
`started` date NOT NULL,
`ended` date DEFAULT NULL,
`warehouseFk` smallint(5) unsigned DEFAULT NULL,
`created` timestamp NOT NULL DEFAULT current_timestamp(),
2024-07-12 05:58:59 +00:00
`editorFk` int(10) unsigned DEFAULT NULL,
2024-07-11 06:57:45 +00:00
PRIMARY KEY (`id`),
UNIQUE KEY `itemMinimumQuantity_UNIQUE` (`itemFk`, `started`, `ended`, `warehouseFk`),
KEY `itemFk` (`itemFk`),
KEY `started` (`started`),
KEY `ended` (`ended`),
KEY `warehouseFk` (`warehouseFk`),
2024-07-12 05:58:59 +00:00
KEY `editorFk` (`editorFk`),
2024-07-11 06:57:45 +00:00
CONSTRAINT `itemMinimumQuantity_ibfk_1` FOREIGN KEY (`itemFk`) REFERENCES `item` (`id`) ON DELETE CASCADE ON UPDATE CASCADE,
2024-07-11 11:45:24 +00:00
CONSTRAINT `itemMinimumQuantity_ibfk_2` FOREIGN KEY (`warehouseFk`) REFERENCES `warehouse` (`id`) ON UPDATE CASCADE,
2024-07-12 05:58:59 +00:00
CONSTRAINT `itemMinimumQuantity_ibfk_3` FOREIGN KEY (`editorFk`) REFERENCES `account`.`user` (`id`),
2024-07-11 11:45:24 +00:00
CONSTRAINT `itemMinimumQuantity_check_1` CHECK (`started` <= `ended`)
2024-07-11 06:57:45 +00:00
) ENGINE=InnoDB AUTO_INCREMENT=0 DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_unicode_ci;
2024-07-11 07:54:49 +00:00
GRANT SELECT, UPDATE, DELETE, INSERT ON TABLE vn.itemMinimumQuantity TO buyer;
2024-07-11 11:25:26 +00:00
GRANT EXECUTE ON PROCEDURE vn.ticketCalculatePurge TO guest;