Add SQL query for average cost retrieval and generate TriggerLog model

This commit is contained in:
2025-12-14 10:15:57 +03:30
parent 41d7dd8802
commit 9d7d94b5f8
45 changed files with 3742 additions and 440 deletions
@@ -0,0 +1,21 @@
/*
Warnings:
- The primary key for the `Stock_Balance` table will be changed. If it partially fails, the table could be left without primary key constraint.
- You are about to drop the column `ProductId` on the `Stock_Balance` table. All the data in the column will be lost.
- Added the required column `inventoryId` to the `Stock_Balance` table without a default value. This is not possible if the table is not empty.
- Added the required column `productId` to the `Stock_Balance` table without a default value. This is not possible if the table is not empty.
*/
-- AlterTable
ALTER TABLE `Stock_Balance` DROP PRIMARY KEY,
DROP COLUMN `ProductId`,
ADD COLUMN `inventoryId` INTEGER NOT NULL,
ADD COLUMN `productId` INTEGER NOT NULL,
ADD PRIMARY KEY (`productId`);
-- AddForeignKey
ALTER TABLE `Stock_Balance` ADD CONSTRAINT `Stock_Balance_productId_fkey` FOREIGN KEY (`productId`) REFERENCES `Products`(`id`) ON DELETE RESTRICT ON UPDATE CASCADE;
-- AddForeignKey
ALTER TABLE `Stock_Balance` ADD CONSTRAINT `Stock_Balance_inventoryId_fkey` FOREIGN KEY (`inventoryId`) REFERENCES `Inventories`(`id`) ON DELETE RESTRICT ON UPDATE CASCADE;