2024-10-22 13:00:16 +00:00
|
|
|
CREATE TABLE IF NOT EXISTS `vn`.`itemCampaign` (
|
2024-10-18 05:35:36 +00:00
|
|
|
`id` int(11) NOT NULL PRIMARY KEY AUTO_INCREMENT,
|
2024-10-17 08:08:27 +00:00
|
|
|
dated date NOT NULL,
|
|
|
|
itemFk int(11) NOT NULL,
|
|
|
|
quantity decimal(10,2) NOT NULL,
|
2024-10-22 06:41:46 +00:00
|
|
|
total decimal(10,2) NOT NULL,
|
2024-10-17 08:08:27 +00:00
|
|
|
campaign varchar(100) NOT NULL,
|
2024-10-22 13:00:16 +00:00
|
|
|
UNIQUE KEY `itemCampaign_UNIQUE` (`dated`,`itemFk`),
|
|
|
|
CONSTRAINT itemCampaign_item_FK FOREIGN KEY (itemFk) REFERENCES vn.item(id) ON DELETE RESTRICT ON UPDATE CASCADE
|
2024-10-17 08:08:27 +00:00
|
|
|
)
|
|
|
|
ENGINE=InnoDB
|
|
|
|
DEFAULT CHARSET=utf8mb3
|
2024-10-18 05:35:36 +00:00
|
|
|
COLLATE=utf8mb3_unicode_ci
|
2024-10-18 05:44:28 +00:00
|
|
|
COMMENT='Tallos confirmados por día en los días de más producción de una campaña. La tabla está pensada para que sea una foto.';
|
2024-10-17 08:08:27 +00:00
|
|
|
|
2024-10-22 13:00:16 +00:00
|
|
|
ALTER TABLE vn.campaign
|
|
|
|
ADD previousDays int(10) unsigned DEFAULT 30 NOT NULL COMMENT 'Días previos para calcular e insertar en la tabla itemCampaign';
|
|
|
|
|
|
|
|
UPDATE vn.campaign
|
|
|
|
SET previousDays = 90
|
|
|
|
WHERE code = 'allSaints';
|
2024-10-17 08:08:27 +00:00
|
|
|
|
2024-10-22 13:00:16 +00:00
|
|
|
UPDATE vn.campaign
|
|
|
|
SET previousDays = 60
|
|
|
|
WHERE code IN ('valentinesDay', 'mothersDay');
|