feat: implement meal planning feature with CRUD operations and UI integration
This commit is contained in:
@@ -0,0 +1,15 @@
|
||||
-- CreateTable
|
||||
CREATE TABLE `MealPlanEntry` (
|
||||
`id` INTEGER NOT NULL AUTO_INCREMENT,
|
||||
`date` DATE NOT NULL,
|
||||
`recipeId` INTEGER NOT NULL,
|
||||
`createdAt` DATETIME(3) NOT NULL DEFAULT CURRENT_TIMESTAMP(3),
|
||||
`updatedAt` DATETIME(3) NOT NULL,
|
||||
|
||||
UNIQUE INDEX `MealPlanEntry_date_key`(`date`),
|
||||
INDEX `MealPlanEntry_date_idx`(`date`),
|
||||
PRIMARY KEY (`id`)
|
||||
) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
|
||||
|
||||
-- AddForeignKey
|
||||
ALTER TABLE `MealPlanEntry` ADD CONSTRAINT `MealPlanEntry_recipeId_fkey` FOREIGN KEY (`recipeId`) REFERENCES `Recipe`(`id`) ON DELETE CASCADE ON UPDATE CASCADE;
|
||||
@@ -69,7 +69,8 @@ model Recipe {
|
||||
createdAt DateTime @default(now())
|
||||
updatedAt DateTime @updatedAt
|
||||
|
||||
ingredients RecipeIngredient[]
|
||||
ingredients RecipeIngredient[]
|
||||
mealPlanEntries MealPlanEntry[]
|
||||
}
|
||||
|
||||
model RecipeIngredient {
|
||||
@@ -92,4 +93,16 @@ model PantryItem {
|
||||
product Product @relation(fields: [productId], references: [id], onDelete: Cascade)
|
||||
createdAt DateTime @default(now())
|
||||
updatedAt DateTime @updatedAt
|
||||
}
|
||||
|
||||
model MealPlanEntry {
|
||||
id Int @id @default(autoincrement())
|
||||
date DateTime @db.Date
|
||||
recipe Recipe @relation(fields: [recipeId], references: [id], onDelete: Cascade)
|
||||
recipeId Int
|
||||
createdAt DateTime @default(now())
|
||||
updatedAt DateTime @updatedAt
|
||||
|
||||
@@unique([date])
|
||||
@@index([date])
|
||||
}
|
||||
Reference in New Issue
Block a user