Files
2026-09-08 17:46:28 +08:00

62 lines
1.9 KiB
Plaintext

// Production Prisma schema for the IT Cost Dashboard (MySQL / AWS RDS).
//
// This mirrors prisma/schema.prisma exactly except the datasource provider is
// "mysql". Prisma does NOT support env() for the `provider` field, so dev
// (SQLite) and prod (MySQL) each need their own schema file + migrations.
//
// Usage on the production EC2 box (see DEPLOY.md):
// npm run prod:generate # prisma generate --schema=prisma/prod/schema.prisma
// npm run prod:migrate # prisma migrate deploy --schema=prisma/prod/schema.prisma
// npm run build:prod
datasource db {
provider = "mysql"
url = env("DATABASE_URL")
}
generator client {
provider = "prisma-client-js"
}
// One row per (name, region, year). e.g. "Cloud Hosting" in AMEA IT 2026 is a
// distinct row from "Cloud Hosting" in EMEA IT 2026. Cost is never stored — it is
// always derived as SUM(subItems.subCost).
model CostItem {
id Int @id @default(autoincrement())
name String
region String
year Int
subItems SubCostItem[]
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
@@index([region, year])
}
model SubCostItem {
id Int @id @default(autoincrement())
name String
subCost Float
costItem CostItem @relation(fields: [costItemId], references: [id], onDelete: Cascade)
costItemId Int
@@index([costItemId])
}
// The TrendAI percentage that splits each item's Cost into TrendAI vs TrendLife
// for a given region+year. Applies uniformly to all items in that region+year.
model TrendAiPercentage {
id Int @id @default(autoincrement())
region String
year Int
percentage Float
@@unique([region, year])
}
// The set of years available for selection across the app. Managed on the Year
// Creation page. Cost items reference years by value (not FK) so a year can exist
// with no cost data yet.
model Year {
year Int @id
}