157 lines
3.9 KiB
Plaintext
157 lines
3.9 KiB
Plaintext
generator client {
|
|
provider = "prisma-client-js"
|
|
}
|
|
|
|
datasource db {
|
|
provider = "sqlite"
|
|
url = "file:./dev.db"
|
|
}
|
|
|
|
model Store {
|
|
id String @id @default(cuid())
|
|
slug String @unique
|
|
stripeAccountId String? @unique
|
|
userId String @unique
|
|
user User @relation(fields: [userId], references: [id])
|
|
name String?
|
|
website String?
|
|
defaultSellingPreferences Json?
|
|
createdAt DateTime @default(now())
|
|
updatedAt DateTime @updatedAt
|
|
carts Cart[]
|
|
products ProductCache[]
|
|
}
|
|
|
|
model Cart {
|
|
id String @id @default(cuid())
|
|
storeId String
|
|
store Store @relation(fields: [storeId], references: [id])
|
|
sessionId String
|
|
userId String?
|
|
user User? @relation(fields: [userId], references: [id])
|
|
items CartItem[]
|
|
createdAt DateTime @default(now())
|
|
updatedAt DateTime @updatedAt
|
|
|
|
@@unique([storeId, sessionId])
|
|
@@unique([storeId, userId])
|
|
}
|
|
|
|
model CartItem {
|
|
id String @id @default(cuid())
|
|
cartId String
|
|
cart Cart @relation(fields: [cartId], references: [id])
|
|
productId String
|
|
priceId String
|
|
name String
|
|
unitAmount Int
|
|
currency String
|
|
quantity Int
|
|
createdAt DateTime @default(now())
|
|
updatedAt DateTime @updatedAt
|
|
}
|
|
|
|
model UserAddress {
|
|
id String @id @default(cuid())
|
|
userId String @unique
|
|
user User @relation(fields: [userId], references: [id])
|
|
name String
|
|
street1 String
|
|
city String
|
|
state String
|
|
zip String
|
|
country String
|
|
phone String?
|
|
createdAt DateTime @default(now())
|
|
updatedAt DateTime @updatedAt
|
|
}
|
|
|
|
model Order {
|
|
id String @id @default(cuid())
|
|
storeId String
|
|
userId String?
|
|
sessionId String?
|
|
stripeCheckoutSessionId String @unique
|
|
shippingRateId String?
|
|
shippingRateSnapshot Json?
|
|
shippingAddress Json?
|
|
items Json
|
|
status String
|
|
labelUrl String?
|
|
createdAt DateTime @default(now())
|
|
updatedAt DateTime @updatedAt
|
|
}
|
|
|
|
model ProductCache {
|
|
id String @id @default(cuid())
|
|
storeId String
|
|
store Store @relation(fields: [storeId], references: [id])
|
|
stripeProductId String
|
|
stripePriceId String
|
|
name String
|
|
description String?
|
|
unitAmount Int
|
|
currency String
|
|
active Boolean @default(true)
|
|
createdAt DateTime @default(now())
|
|
updatedAt DateTime @updatedAt
|
|
|
|
@@unique([storeId, stripeProductId])
|
|
}
|
|
|
|
model User {
|
|
id String @id @default(cuid())
|
|
name String
|
|
email String @unique
|
|
passwordHash String
|
|
role Role @default(CUSTOMER)
|
|
createdAt DateTime @default(now())
|
|
updatedAt DateTime @updatedAt
|
|
store Store?
|
|
carts Cart[]
|
|
address UserAddress?
|
|
accounts Account[]
|
|
sessions Session[]
|
|
}
|
|
|
|
model Session {
|
|
id String @id @default(cuid())
|
|
sessionToken String @unique
|
|
userId String
|
|
user User @relation(fields: [userId], references: [id])
|
|
expires DateTime
|
|
createdAt DateTime @default(now())
|
|
updatedAt DateTime @updatedAt
|
|
}
|
|
|
|
enum Role {
|
|
OWNER
|
|
CUSTOMER
|
|
}
|
|
|
|
model Account {
|
|
id String @id @default(cuid())
|
|
userId String
|
|
type String
|
|
provider String
|
|
providerAccountId String
|
|
refresh_token String?
|
|
access_token String?
|
|
expires_at Int?
|
|
token_type String?
|
|
scope String?
|
|
id_token String?
|
|
session_state String?
|
|
user User @relation(fields: [userId], references: [id])
|
|
|
|
@@unique([provider, providerAccountId])
|
|
}
|
|
|
|
model VerificationToken {
|
|
identifier String
|
|
token String @unique
|
|
expires DateTime
|
|
|
|
@@unique([identifier, token])
|
|
}
|