Files
jh-monitor/prisma/schema.prisma
2025-09-13 14:00:56 +08:00

161 lines
4.8 KiB
Plaintext

generator client {
provider = "prisma-client-js"
binaryTargets = ["native", "debian-openssl-3.0.x"]
}
datasource db {
provider = "mysql"
url = env("DATABASE_URL")
}
model change {
id Int @id @default(autoincrement())
time DateTime? @db.Timestamp(0)
city Int?
macaddr String @db.VarChar(20)
edge_new String @db.VarChar(20)
edge_old String? @db.VarChar(20)
info String @db.VarChar(500)
network String @db.VarChar(20)
createtime DateTime @default(now()) @db.DateTime(0)
@@index([edge_new], map: "edge_new")
@@index([time], map: "change_time_index")
}
/// This model or at least one of its fields has comments in the database, and requires an additional setup for migrations: Read more: https://pris.ly/d/database-comments
model cityhash {
id Int @id @default(autoincrement()) @db.UnsignedInt
macaddr String? @db.VarChar(20)
city String @db.VarChar(20)
num Int
hash String @db.VarChar(100)
label String? @db.VarChar(20)
count Int @default(0)
offset Int @default(0)
createtime DateTime @default(now()) @db.DateTime(0)
updatetime DateTime @default(now()) @db.DateTime(0)
}
/// This model or at least one of its fields has comments in the database, and requires an additional setup for migrations: Read more: https://pris.ly/d/database-comments
model edge {
id Int @id @default(autoincrement())
macaddr String @unique(map: "edge_macaddr_idx") @db.VarChar(17)
public String @db.VarChar(255)
isp String @db.VarChar(255)
single Boolean
sole Boolean
arch Boolean
online Int @default(0)
city_id Int
active Boolean
@@index([active], map: "edge_active_index")
@@index([city_id])
@@index([isp], map: "edge_isp_index")
@@index([public], map: "edge_public_index")
}
model gateway {
id Int @id @default(autoincrement()) @db.UnsignedInt
macaddr String @db.VarChar(20)
table Int
edge String @db.VarChar(20)
network String @db.VarChar(20)
cityhash String @db.VarChar(100)
label String? @db.VarChar(20)
user String? @db.VarChar(20)
inner_ip String? @db.VarChar(20)
ischange Int @default(0) @db.TinyInt
isonline Int @default(0) @db.TinyInt
onlinenum Int @default(0)
createtime DateTime @default(now()) @db.DateTime(0)
updatetime DateTime @default(now()) @db.DateTime(0)
@@index([inner_ip], map: "inner_ip")
}
/// This model or at least one of its fields has comments in the database, and requires an additional setup for migrations: Read more: https://pris.ly/d/database-comments
model token {
id Int @id @default(autoincrement()) @db.UnsignedInt
setid Int @default(1)
change_count Int
limit_count Int @default(32000)
token String @db.VarChar(1000)
macaddr String @db.VarChar(100)
token_time DateTime @db.DateTime(0)
inner_ip String? @db.VarChar(20)
l2ip String? @db.VarChar(20)
enable Boolean @default(true)
createtime DateTime @default(now()) @db.DateTime(0)
updatetime DateTime @default(now()) @db.DateTime(0)
}
model change_city {
id Int @id @default(autoincrement())
time DateTime? @db.Timestamp(0)
city_id Int?
count Int?
offset_old Int?
offset_new Int?
@@index([time], map: "change_city_time_index")
}
model Account {
id String @id @default(cuid())
userId Int @map("user_id")
type String
provider String
providerAccountId String @map("provider_account_id")
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?
user User @relation(fields: [userId], references: [id], onDelete: Cascade)
@@unique([provider, providerAccountId])
@@map("accounts")
}
model User {
id Int @id @default(autoincrement())
phone String @unique
password String
name String?
verifiedPhone Boolean @default(false)
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
sessions Session[]
accounts Account[]
@@map("users")
}
model Session {
id String @id
userId Int
user User @relation(fields: [userId], references: [id], onDelete: Cascade)
expires DateTime
createdAt DateTime @default(now())
@@index([userId])
@@map("sessions")
}
model VerificationCode {
id Int @id @default(autoincrement())
phone String
code String
type String
expiresAt DateTime
createdAt DateTime @default(now())
@@index([phone, type])
@@map("verification_codes")
}