149 lines
3.6 KiB
Plaintext
149 lines
3.6 KiB
Plaintext
// This is your Prisma schema file,
|
|
// learn more about it in the docs: https://pris.ly/d/prisma-schema
|
|
|
|
generator client {
|
|
provider = "prisma-client-js"
|
|
}
|
|
|
|
datasource db {
|
|
provider = "postgresql"
|
|
url = env("DATABASE_URL")
|
|
}
|
|
|
|
enum UserRole {
|
|
ADMIN
|
|
USER
|
|
}
|
|
|
|
model Account {
|
|
id String @id @default(cuid())
|
|
userId String
|
|
type String
|
|
provider String
|
|
providerAccountId String
|
|
refresh_token String? @db.Text
|
|
access_token String? @db.Text
|
|
expires_at Int?
|
|
token_type String?
|
|
scope String?
|
|
id_token String? @db.Text
|
|
session_state String?
|
|
createdAt DateTime @default(now()) @map(name: "created_at")
|
|
updatedAt DateTime @default(now()) @map(name: "updated_at")
|
|
|
|
user User @relation(fields: [userId], references: [id], onDelete: Cascade)
|
|
|
|
@@unique([provider, providerAccountId])
|
|
@@index([userId])
|
|
@@map(name: "accounts")
|
|
}
|
|
|
|
model Session {
|
|
id String @id @default(cuid())
|
|
sessionToken String @unique
|
|
userId String
|
|
expires DateTime
|
|
user User @relation(fields: [userId], references: [id], onDelete: Cascade)
|
|
|
|
@@index([userId])
|
|
@@map(name: "sessions")
|
|
}
|
|
|
|
model User {
|
|
id String @id @default(cuid())
|
|
name String?
|
|
email String? @unique
|
|
emailVerified DateTime?
|
|
image String?
|
|
active Int @default(1) // 0 封禁,1 正常
|
|
team String?
|
|
createdAt DateTime @default(now()) @map(name: "created_at")
|
|
updatedAt DateTime @default(now()) @map(name: "updated_at")
|
|
role UserRole @default(USER)
|
|
|
|
accounts Account[]
|
|
sessions Session[]
|
|
UserRecord UserRecord[]
|
|
UserUrl UserUrl[]
|
|
|
|
@@map(name: "users")
|
|
}
|
|
|
|
model VerificationToken {
|
|
identifier String
|
|
token String @unique
|
|
expires DateTime
|
|
|
|
@@unique([identifier, token])
|
|
@@map(name: "verification_tokens")
|
|
}
|
|
|
|
model UserRecord {
|
|
id String @id @default(cuid())
|
|
userId String
|
|
record_id String @unique
|
|
zone_id String
|
|
zone_name String
|
|
name String
|
|
type String
|
|
content String
|
|
proxiable Boolean?
|
|
proxied Boolean?
|
|
ttl Int?
|
|
comment String?
|
|
tags String
|
|
created_on DateTime?
|
|
modified_on DateTime?
|
|
active Int? @default(1)
|
|
|
|
user User @relation(fields: [userId], references: [id], onDelete: Cascade)
|
|
|
|
@@index([userId])
|
|
@@map(name: "user_records")
|
|
}
|
|
|
|
model UserUrl {
|
|
id String @id @default(cuid())
|
|
userId String
|
|
userName String
|
|
target String
|
|
url String @unique
|
|
visible Int @default(0)
|
|
active Int @default(1)
|
|
expiration String @default("-1")
|
|
createdAt DateTime @default(now()) @map(name: "created_at")
|
|
updatedAt DateTime @default(now()) @map(name: "updated_at")
|
|
|
|
user User @relation(fields: [userId], references: [id], onDelete: Cascade)
|
|
UrlMeta UrlMeta[]
|
|
|
|
@@index([userId])
|
|
@@map(name: "user_urls")
|
|
}
|
|
|
|
model UrlMeta {
|
|
id String @id @default(cuid())
|
|
urlId String
|
|
click Int
|
|
|
|
ip String @default("127.0.0.1")
|
|
city String?
|
|
country String?
|
|
region String?
|
|
latitude String?
|
|
longitude String?
|
|
referer String?
|
|
lang String?
|
|
device String?
|
|
browser String?
|
|
|
|
createdAt DateTime @default(now()) @map(name: "created_at")
|
|
updatedAt DateTime @default(now()) @map(name: "updated_at")
|
|
|
|
userUrl UserUrl @relation(fields: [urlId], references: [id], onDelete: Cascade)
|
|
|
|
@@unique([urlId, ip])
|
|
@@index([urlId])
|
|
@@map(name: "url_metas")
|
|
}
|