CREATE TABLE `delivery_lot_allocations` (
	`id` int AUTO_INCREMENT NOT NULL,
	`deliveryLineId` int NOT NULL,
	`stockLotId` int NOT NULL,
	`quantity` int NOT NULL,
	`createdAt` timestamp NOT NULL DEFAULT (now()),
	CONSTRAINT `delivery_lot_allocations_id` PRIMARY KEY(`id`)
);
--> statement-breakpoint
CREATE TABLE `sale_lot_allocations` (
	`id` int AUTO_INCREMENT NOT NULL,
	`saleItemId` int NOT NULL,
	`stockLotId` int NOT NULL,
	`quantity` int NOT NULL,
	`createdAt` timestamp NOT NULL DEFAULT (now()),
	CONSTRAINT `sale_lot_allocations_id` PRIMARY KEY(`id`)
);
--> statement-breakpoint
ALTER TABLE `production_orders` ADD `laborCostCents` int DEFAULT 0 NOT NULL;--> statement-breakpoint
ALTER TABLE `production_orders` ADD `overheadCostCents` int DEFAULT 0 NOT NULL;--> statement-breakpoint
ALTER TABLE `production_orders` ADD `transformationCostCents` int DEFAULT 0 NOT NULL;--> statement-breakpoint
ALTER TABLE `production_outputs` ADD `expiryDate` timestamp;--> statement-breakpoint
CREATE INDEX `delivery_lot_allocations_line_index` ON `delivery_lot_allocations` (`deliveryLineId`);--> statement-breakpoint
CREATE INDEX `sale_lot_allocations_item_index` ON `sale_lot_allocations` (`saleItemId`);--> statement-breakpoint
CREATE INDEX `sale_lot_allocations_lot_index` ON `sale_lot_allocations` (`stockLotId`);