feat: implement receipt alias functionality with CRUD operations and integrate with receipt import
This commit is contained in:
@@ -0,0 +1,14 @@
|
||||
-- CreateTable
|
||||
CREATE TABLE `ReceiptAlias` (
|
||||
`id` INTEGER NOT NULL AUTO_INCREMENT,
|
||||
`receiptName` VARCHAR(191) NOT NULL,
|
||||
`productId` INTEGER NOT NULL,
|
||||
`createdAt` DATETIME(3) NOT NULL DEFAULT CURRENT_TIMESTAMP(3),
|
||||
|
||||
UNIQUE INDEX `ReceiptAlias_receiptName_key`(`receiptName`),
|
||||
INDEX `ReceiptAlias_productId_idx`(`productId`),
|
||||
PRIMARY KEY (`id`)
|
||||
) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
|
||||
|
||||
-- AddForeignKey
|
||||
ALTER TABLE `ReceiptAlias` ADD CONSTRAINT `ReceiptAlias_productId_fkey` FOREIGN KEY (`productId`) REFERENCES `Product`(`id`) ON DELETE CASCADE ON UPDATE CASCADE;
|
||||
@@ -21,6 +21,7 @@ model Product {
|
||||
inventoryItems InventoryItem[]
|
||||
recipeIngredients RecipeIngredient[]
|
||||
pantryItems PantryItem[]
|
||||
receiptAliases ReceiptAlias[]
|
||||
}
|
||||
|
||||
model InventoryItem {
|
||||
@@ -95,6 +96,14 @@ model PantryItem {
|
||||
updatedAt DateTime @updatedAt
|
||||
}
|
||||
|
||||
model ReceiptAlias {
|
||||
id Int @id @default(autoincrement())
|
||||
receiptName String @unique // normaliserat kvittonamn (lowercase, trim)
|
||||
productId Int
|
||||
product Product @relation(fields: [productId], references: [id], onDelete: Cascade)
|
||||
createdAt DateTime @default(now())
|
||||
}
|
||||
|
||||
model MealPlanEntry {
|
||||
id Int @id @default(autoincrement())
|
||||
date DateTime @db.Date
|
||||
|
||||
Reference in New Issue
Block a user