CREATE TABLE `production_consumption_lots` (
	`id` int AUTO_INCREMENT NOT NULL,
	`consumptionId` int NOT NULL,
	`stockLotId` int NOT NULL,
	`quantity` decimal(20,6) NOT NULL,
	CONSTRAINT `production_consumption_lots_id` PRIMARY KEY(`id`)
);
--> statement-breakpoint
ALTER TABLE `inventory_adjustments` MODIFY COLUMN `quantityChange` decimal(20,6) NOT NULL;--> statement-breakpoint
ALTER TABLE `production_material_consumptions` MODIFY COLUMN `quantity` decimal(20,6) NOT NULL;--> statement-breakpoint
ALTER TABLE `production_recipe_lines` MODIFY COLUMN `quantityPerBatch` decimal(20,6) NOT NULL;--> statement-breakpoint
ALTER TABLE `stock_items` MODIFY COLUMN `quantity` decimal(20,6) NOT NULL;--> statement-breakpoint
ALTER TABLE `stock_lots` MODIFY COLUMN `quantity` decimal(20,6) NOT NULL;--> statement-breakpoint
ALTER TABLE `stock_lots` MODIFY COLUMN `availableQuantity` decimal(20,6) NOT NULL;--> statement-breakpoint
ALTER TABLE `production_orders` ADD `formulaSnapshotJson` text;--> statement-breakpoint
ALTER TABLE `production_orders` ADD `formulaAppliedAt` timestamp;--> statement-breakpoint
ALTER TABLE `production_recipes` ADD `batchOutputQuantity` int DEFAULT 1 NOT NULL;--> statement-breakpoint
CREATE INDEX `production_consumption_lots_consumption_index` ON `production_consumption_lots` (`consumptionId`);