Initial commit: add .gitignore and README
This commit is contained in:
138
prisma/schema.prisma
Normal file
138
prisma/schema.prisma
Normal file
@@ -0,0 +1,138 @@
|
||||
// This is your Prisma schema file,
|
||||
// learn more about the schema in https://pris.ly/d/prisma-schema
|
||||
|
||||
generator client {
|
||||
provider = "prisma-client-js"
|
||||
}
|
||||
|
||||
datasource db {
|
||||
provider = "postgresql"
|
||||
url = env("DATABASE_URL")
|
||||
}
|
||||
|
||||
model Site {
|
||||
id String @id @default(uuid())
|
||||
omadaSiteId String @unique @map("omada_site_id")
|
||||
name String
|
||||
region String?
|
||||
timezone String?
|
||||
country String?
|
||||
address String?
|
||||
contact String?
|
||||
phone String?
|
||||
email String?
|
||||
note String?
|
||||
createdAt DateTime @default(now()) @map("created_at")
|
||||
updatedAt DateTime @updatedAt @map("updated_at")
|
||||
|
||||
devices Device[]
|
||||
vlans Vlan[]
|
||||
|
||||
@@map("sites")
|
||||
@@index([omadaSiteId])
|
||||
}
|
||||
|
||||
model Device {
|
||||
id String @id @default(uuid())
|
||||
omadaDeviceId String? @map("omada_device_id")
|
||||
mac String
|
||||
siteId String @map("site_id")
|
||||
name String
|
||||
ip String?
|
||||
model String
|
||||
type String
|
||||
status String
|
||||
healthScore Int? @map("health_score")
|
||||
firmwareVersion String? @map("firmware_version")
|
||||
licenseStatus String? @map("license_status")
|
||||
licenseDueDate DateTime? @map("license_due_date")
|
||||
lastSeenAt DateTime? @map("last_seen_at")
|
||||
createdAt DateTime @default(now()) @map("created_at")
|
||||
updatedAt DateTime @updatedAt @map("updated_at")
|
||||
|
||||
site Site @relation(fields: [siteId], references: [id], onDelete: Cascade)
|
||||
configApplied DeviceConfigApplied[]
|
||||
|
||||
@@unique([siteId, mac])
|
||||
@@map("devices")
|
||||
@@index([siteId])
|
||||
@@index([mac])
|
||||
@@index([omadaDeviceId])
|
||||
@@index([status])
|
||||
}
|
||||
|
||||
model ConfigTemplate {
|
||||
id String @id @default(uuid())
|
||||
name String
|
||||
type String // gateway, switch, ssid, etc.
|
||||
payload Json // Omada config schema
|
||||
description String?
|
||||
createdBy String? @map("created_by")
|
||||
createdAt DateTime @default(now()) @map("created_at")
|
||||
updatedAt DateTime @updatedAt @map("updated_at")
|
||||
|
||||
configApplied DeviceConfigApplied[]
|
||||
|
||||
@@map("config_templates")
|
||||
@@index([type])
|
||||
}
|
||||
|
||||
model DeviceConfigApplied {
|
||||
id String @id @default(uuid())
|
||||
deviceId String @map("device_id")
|
||||
configTemplateId String @map("config_template_id")
|
||||
status String // pending, success, failed
|
||||
appliedAt DateTime? @map("applied_at")
|
||||
resultPayload Json? @map("result_payload")
|
||||
errorMessage String? @map("error_message")
|
||||
createdAt DateTime @default(now()) @map("created_at")
|
||||
updatedAt DateTime @updatedAt @map("updated_at")
|
||||
|
||||
device Device @relation(fields: [deviceId], references: [id], onDelete: Cascade)
|
||||
template ConfigTemplate @relation(fields: [configTemplateId], references: [id])
|
||||
|
||||
@@map("device_config_applied")
|
||||
@@index([deviceId])
|
||||
@@index([configTemplateId])
|
||||
@@index([status])
|
||||
}
|
||||
|
||||
model Vlan {
|
||||
id String @id @default(uuid())
|
||||
omadaVlanId String? @map("omada_vlan_id")
|
||||
siteId String @map("site_id")
|
||||
name String
|
||||
vlanId Int @map("vlan_id")
|
||||
subnet String
|
||||
gateway String?
|
||||
dhcpEnabled Boolean @default(false) @map("dhcp_enabled")
|
||||
description String?
|
||||
createdAt DateTime @default(now()) @map("created_at")
|
||||
updatedAt DateTime @updatedAt @map("updated_at")
|
||||
|
||||
site Site @relation(fields: [siteId], references: [id], onDelete: Cascade)
|
||||
|
||||
@@unique([siteId, vlanId])
|
||||
@@map("vlans")
|
||||
@@index([siteId])
|
||||
@@index([vlanId])
|
||||
@@index([omadaVlanId])
|
||||
}
|
||||
|
||||
model AuditLog {
|
||||
id String @id @default(uuid())
|
||||
userId String? @map("user_id")
|
||||
serviceAccount String? @map("service_account")
|
||||
action String // e.g., "set_port_vlan", "reboot_device"
|
||||
targetType String @map("target_type") // site, device, client
|
||||
targetId String @map("target_id")
|
||||
details Json? // Additional context
|
||||
timestamp DateTime @default(now())
|
||||
|
||||
@@map("audit_logs")
|
||||
@@index([userId])
|
||||
@@index([action])
|
||||
@@index([targetType, targetId])
|
||||
@@index([timestamp])
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user