salix/db/changes/10300-newFacility/01-waste.sql

22 lines
577 B
SQL

ALTER TABLE `bs`.`waste`
ADD itemFk INT NULL AFTER `family`;
ALTER TABLE `bs`.`waste`
ADD itemTypeFk SMALLINT(5) UNSIGNED NULL AFTER `itemFk`;
ALTER TABLE `bs`.`waste`
ADD CONSTRAINT waste_itemType_id
FOREIGN KEY (itemTypeFk) REFERENCES vn.itemType (id)
ON UPDATE CASCADE;
ALTER TABLE `bs`.`waste`
ADD CONSTRAINT waste_item_id
FOREIGN KEY (itemFk) REFERENCES vn.item (id)
ON UPDATE CASCADE;
ALTER TABLE `bs`.`waste` DROP PRIMARY KEY;
ALTER TABLE `bs`.`waste`
ADD PRIMARY KEY (buyer, `year`, week, family, itemFk);