add schema for box and item
add mobile version for datatable
This commit is contained in:
@@ -9,44 +9,46 @@ datasource db {
|
||||
}
|
||||
|
||||
model User {
|
||||
id String @id @default(uuid())
|
||||
name String
|
||||
email String
|
||||
emailVerified Boolean @default(false)
|
||||
image String?
|
||||
createdAt DateTime @default(now()) @db.Timestamptz
|
||||
updatedAt DateTime @updatedAt @db.Timestamptz
|
||||
sessions Session[]
|
||||
accounts Account[]
|
||||
audit Audit[]
|
||||
notification Notification[]
|
||||
id String @id @default(uuid())
|
||||
name String
|
||||
email String
|
||||
emailVerified Boolean @default(false)
|
||||
image String?
|
||||
createdAt DateTime @default(now()) @db.Timestamptz
|
||||
updatedAt DateTime @updatedAt @db.Timestamptz
|
||||
sessions Session[]
|
||||
accounts Account[]
|
||||
audit Audit[]
|
||||
notification Notification[]
|
||||
|
||||
role String?
|
||||
banned Boolean? @default(false)
|
||||
banReason String?
|
||||
banExpires DateTime?
|
||||
role String?
|
||||
banned Boolean? @default(false)
|
||||
banReason String?
|
||||
banExpires DateTime?
|
||||
|
||||
members Member[]
|
||||
invitations Invitation[]
|
||||
members Member[]
|
||||
invitations Invitation[]
|
||||
boxes Box[]
|
||||
items Item[]
|
||||
|
||||
@@unique([email])
|
||||
@@map("user")
|
||||
}
|
||||
|
||||
model Session {
|
||||
id String @id @default(uuid())
|
||||
expiresAt DateTime @db.Timestamptz
|
||||
token String
|
||||
createdAt DateTime @default(now()) @db.Timestamptz
|
||||
updatedAt DateTime @updatedAt @db.Timestamptz
|
||||
ipAddress String?
|
||||
userAgent String?
|
||||
userId String
|
||||
user User @relation(fields: [userId], references: [id], onDelete: Cascade)
|
||||
id String @id @default(uuid())
|
||||
expiresAt DateTime @db.Timestamptz
|
||||
token String
|
||||
createdAt DateTime @default(now()) @db.Timestamptz
|
||||
updatedAt DateTime @updatedAt @db.Timestamptz
|
||||
ipAddress String?
|
||||
userAgent String?
|
||||
userId String
|
||||
user User @relation(fields: [userId], references: [id], onDelete: Cascade)
|
||||
|
||||
impersonatedBy String?
|
||||
impersonatedBy String?
|
||||
|
||||
activeOrganizationId String?
|
||||
activeOrganizationId String?
|
||||
|
||||
@@unique([token])
|
||||
@@index([userId])
|
||||
@@ -54,60 +56,61 @@ model Session {
|
||||
}
|
||||
|
||||
model Account {
|
||||
id String @id @default(uuid())
|
||||
accountId String
|
||||
providerId String
|
||||
userId String
|
||||
user User @relation(fields: [userId], references: [id], onDelete: Cascade)
|
||||
accessToken String?
|
||||
refreshToken String?
|
||||
idToken String?
|
||||
accessTokenExpiresAt DateTime?
|
||||
refreshTokenExpiresAt DateTime?
|
||||
scope String?
|
||||
password String?
|
||||
createdAt DateTime @default(now()) @db.Timestamptz
|
||||
updatedAt DateTime @updatedAt @db.Timestamptz
|
||||
id String @id @default(uuid())
|
||||
accountId String
|
||||
providerId String
|
||||
userId String
|
||||
user User @relation(fields: [userId], references: [id], onDelete: Cascade)
|
||||
accessToken String?
|
||||
refreshToken String?
|
||||
idToken String?
|
||||
accessTokenExpiresAt DateTime?
|
||||
refreshTokenExpiresAt DateTime?
|
||||
scope String?
|
||||
password String?
|
||||
createdAt DateTime @default(now()) @db.Timestamptz
|
||||
updatedAt DateTime @updatedAt @db.Timestamptz
|
||||
|
||||
@@index([userId])
|
||||
@@map("account")
|
||||
}
|
||||
|
||||
model Verification {
|
||||
id String @id @default(uuid())
|
||||
identifier String
|
||||
value String
|
||||
expiresAt DateTime
|
||||
createdAt DateTime @default(now()) @db.Timestamptz
|
||||
updatedAt DateTime @updatedAt @db.Timestamptz
|
||||
id String @id @default(uuid())
|
||||
identifier String
|
||||
value String
|
||||
expiresAt DateTime
|
||||
createdAt DateTime @default(now()) @db.Timestamptz
|
||||
updatedAt DateTime @updatedAt @db.Timestamptz
|
||||
|
||||
@@index([identifier])
|
||||
@@map("verification")
|
||||
}
|
||||
|
||||
model House {
|
||||
id String @id @default(uuid())
|
||||
name String
|
||||
slug String
|
||||
logo String?
|
||||
createdAt DateTime @db.Timestamptz
|
||||
metadata String?
|
||||
color String? @default("#000000")
|
||||
members Member[]
|
||||
invitations Invitation[]
|
||||
id String @id @default(uuid())
|
||||
name String
|
||||
slug String
|
||||
logo String?
|
||||
createdAt DateTime @db.Timestamptz
|
||||
metadata String?
|
||||
color String? @default("#000000")
|
||||
members Member[]
|
||||
invitations Invitation[]
|
||||
boxes Box[]
|
||||
|
||||
@@unique([slug])
|
||||
@@map("house")
|
||||
}
|
||||
|
||||
model Member {
|
||||
id String @id @default(uuid())
|
||||
organizationId String
|
||||
house House @relation(fields: [organizationId], references: [id], onDelete: Cascade)
|
||||
userId String
|
||||
user User @relation(fields: [userId], references: [id], onDelete: Cascade)
|
||||
role String @default("member")
|
||||
createdAt DateTime @db.Timestamptz
|
||||
id String @id @default(uuid())
|
||||
organizationId String
|
||||
house House @relation(fields: [organizationId], references: [id], onDelete: Cascade)
|
||||
userId String
|
||||
user User @relation(fields: [userId], references: [id], onDelete: Cascade)
|
||||
role String @default("member")
|
||||
createdAt DateTime @db.Timestamptz
|
||||
|
||||
@@index([organizationId])
|
||||
@@index([userId])
|
||||
@@ -115,16 +118,16 @@ model Member {
|
||||
}
|
||||
|
||||
model Invitation {
|
||||
id String @id @default(uuid())
|
||||
organizationId String
|
||||
house House @relation(fields: [organizationId], references: [id], onDelete: Cascade)
|
||||
email String
|
||||
role String?
|
||||
status String @default("pending")
|
||||
expiresAt DateTime @db.Timestamptz
|
||||
createdAt DateTime @default(now()) @db.Timestamptz
|
||||
inviterId String
|
||||
user User @relation(fields: [inviterId], references: [id], onDelete: Cascade)
|
||||
id String @id @default(uuid())
|
||||
organizationId String
|
||||
house House @relation(fields: [organizationId], references: [id], onDelete: Cascade)
|
||||
email String
|
||||
role String?
|
||||
status String @default("pending")
|
||||
expiresAt DateTime @db.Timestamptz
|
||||
createdAt DateTime @default(now()) @db.Timestamptz
|
||||
inviterId String
|
||||
user User @relation(fields: [inviterId], references: [id], onDelete: Cascade)
|
||||
|
||||
@@index([organizationId])
|
||||
@@index([email])
|
||||
@@ -132,49 +135,99 @@ model Invitation {
|
||||
}
|
||||
|
||||
model Setting {
|
||||
id String @id @default(uuid())
|
||||
key String @unique
|
||||
value String
|
||||
description String
|
||||
relation String @default("admin")
|
||||
id String @id @default(uuid())
|
||||
key String @unique
|
||||
value String
|
||||
description String
|
||||
relation String @default("admin")
|
||||
|
||||
createdAt DateTime @default(now()) @db.Timestamptz
|
||||
updatedAt DateTime @updatedAt @db.Timestamptz
|
||||
createdAt DateTime @default(now()) @db.Timestamptz
|
||||
updatedAt DateTime @updatedAt @db.Timestamptz
|
||||
|
||||
@@map("setting")
|
||||
}
|
||||
|
||||
model Audit {
|
||||
id String @id @default(uuid())
|
||||
userId String
|
||||
action String
|
||||
tableName String
|
||||
recordId String
|
||||
oldValue String?
|
||||
newValue String?
|
||||
createdAt DateTime @default(now()) @db.Timestamptz
|
||||
user User @relation(fields: [userId], references: [id], onDelete: Cascade)
|
||||
id String @id @default(uuid())
|
||||
userId String
|
||||
action String
|
||||
tableName String
|
||||
recordId String
|
||||
oldValue String?
|
||||
newValue String?
|
||||
createdAt DateTime @default(now()) @db.Timestamptz
|
||||
user User @relation(fields: [userId], references: [id], onDelete: Cascade)
|
||||
|
||||
@@map("audit")
|
||||
}
|
||||
|
||||
model Notification {
|
||||
id String @id @default(uuid())
|
||||
userId String
|
||||
id String @id @default(uuid())
|
||||
userId String
|
||||
|
||||
title String
|
||||
message String
|
||||
type String @default("system")
|
||||
title String
|
||||
message String
|
||||
type String @default("system")
|
||||
|
||||
link String?
|
||||
metadata String?
|
||||
link String?
|
||||
metadata String?
|
||||
|
||||
createdAt DateTime @default(now()) @db.Timestamptz
|
||||
readAt DateTime? @db.Timestamptz
|
||||
createdAt DateTime @default(now()) @db.Timestamptz
|
||||
readAt DateTime? @db.Timestamptz
|
||||
|
||||
user User @relation(fields: [userId], references: [id], onDelete: Cascade)
|
||||
user User @relation(fields: [userId], references: [id], onDelete: Cascade)
|
||||
|
||||
@@index([userId, readAt])
|
||||
@@index([readAt])
|
||||
@@map("notification")
|
||||
}
|
||||
|
||||
model Box {
|
||||
id String @id @default(uuid())
|
||||
houseId String?
|
||||
icon String
|
||||
color String
|
||||
name String
|
||||
description String?
|
||||
tags String[] @default([])
|
||||
createrId String
|
||||
|
||||
createdAt DateTime @default(now()) @db.Timestamptz
|
||||
updatedAt DateTime @updatedAt @db.Timestamptz
|
||||
deletedAt DateTime?
|
||||
isPrivate Boolean @default(false)
|
||||
|
||||
items Item[]
|
||||
house House? @relation(fields: [houseId], references: [id], onDelete: SetNull)
|
||||
user User @relation(fields: [createrId], references: [id], onDelete: Cascade)
|
||||
|
||||
@@index([houseId])
|
||||
@@index([createrId])
|
||||
@@index([isPrivate])
|
||||
@@index([tags])
|
||||
@@map("box")
|
||||
}
|
||||
|
||||
model Item {
|
||||
id String @id @default(uuid())
|
||||
createrId String
|
||||
boxId String?
|
||||
image String
|
||||
name String
|
||||
description String?
|
||||
price String?
|
||||
tags String[] @default([])
|
||||
quantity Int
|
||||
expiresAt DateTime @default(now()) @db.Timestamptz
|
||||
createdAt DateTime @default(now()) @db.Timestamptz
|
||||
updatedAt DateTime @updatedAt @db.Timestamptz
|
||||
deletedAt DateTime?
|
||||
|
||||
user User @relation(fields: [createrId], references: [id], onDelete: Cascade)
|
||||
box Box? @relation(fields: [boxId], references: [id], onDelete: SetNull)
|
||||
|
||||
@@index([createrId])
|
||||
@@index([boxId])
|
||||
@@index([tags])
|
||||
@@map("item")
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user