-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathschema.prisma
66 lines (57 loc) · 2.04 KB
/
schema.prisma
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
// schema.prisma
generator client {
provider = "prisma-client-js"
}
datasource db {
provider = "sqlite" // Now using SQLite as the database provider
url = "file:./pantry.db" // The database file will be created in the current directory
}
model Ingredient {
id Int @id @default(autoincrement())
name String @unique
quantity Float // Quantity in a specific unit
unit String // e.g., 'grams', 'liters', 'pieces'
pantryId Int
pantry Pantry @relation(fields: [pantryId], references: [id])
recipes Recipe[] @relation("RecipeIngredients")
expirationDate DateTime? // Optional field for perishable ingredients
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
ShoppingListItem ShoppingListItem[]
}
model Pantry {
id Int @id @default(autoincrement())
name String
ingredients Ingredient[]
shoppingLists ShoppingList[]
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
Recipe Recipe[]
}
model ShoppingList {
id Int @id @default(autoincrement())
name String
pantryId Int
pantry Pantry @relation(fields: [pantryId], references: [id])
items ShoppingListItem[]
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
}
model ShoppingListItem {
id Int @id @default(autoincrement())
shoppingListId Int
ingredientId Int
quantity Float
shoppingList ShoppingList @relation(fields: [shoppingListId], references: [id])
ingredient Ingredient @relation(fields: [ingredientId], references: [id])
}
model Recipe {
id Int @id @default(autoincrement())
name String
instructions String
ingredients Ingredient[] @relation("RecipeIngredients")
pantryId Int
pantry Pantry @relation(fields: [pantryId], references: [id])
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
}