Files
jh-monitor/prisma/schema.prisma
2025-09-25 19:14:48 +08:00

116 lines
3.6 KiB
Plaintext

generator client {
provider = "prisma-client"
output = "../src/generated/prisma"
}
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 User {
id Int @id @default(autoincrement())
account String @unique
password String
name String?
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
sessions Session[]
@@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")
}