- Added new API path for unit mappings in `api_paths.dart`. - Implemented `upsertUnitMapping` method in `ImportRepository` to handle unit mapping creation. - Updated `ReceiptImportTab` to learn and save unit mappings during receipt import. - Created DTO for unit mapping with validation in `create-unit-mapping.dto.ts`. - Added SQL migration for `UnitMapping` table creation with necessary constraints.
This commit is contained in:
@@ -0,0 +1,22 @@
|
||||
CREATE TABLE `UnitMapping` (
|
||||
`id` INTEGER NOT NULL AUTO_INCREMENT,
|
||||
`productId` INTEGER NOT NULL,
|
||||
`originalUnit` VARCHAR(191) NOT NULL,
|
||||
`preferredUnit` VARCHAR(191) NOT NULL,
|
||||
`userId` INTEGER NOT NULL,
|
||||
|
||||
UNIQUE INDEX `UnitMapping_productId_originalUnit_userId_key`(`productId`, `originalUnit`, `userId`),
|
||||
INDEX `UnitMapping_productId_idx`(`productId`),
|
||||
INDEX `UnitMapping_userId_idx`(`userId`),
|
||||
PRIMARY KEY (`id`)
|
||||
) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
|
||||
|
||||
ALTER TABLE `UnitMapping`
|
||||
ADD CONSTRAINT `UnitMapping_productId_fkey`
|
||||
FOREIGN KEY (`productId`) REFERENCES `Product`(`id`)
|
||||
ON DELETE CASCADE ON UPDATE CASCADE;
|
||||
|
||||
ALTER TABLE `UnitMapping`
|
||||
ADD CONSTRAINT `UnitMapping_userId_fkey`
|
||||
FOREIGN KEY (`userId`) REFERENCES `User`(`id`)
|
||||
ON DELETE CASCADE ON UPDATE CASCADE;
|
||||
Reference in New Issue
Block a user