busi488energy/prisma/schema.prisma
Joey Eamigh 8f99f6535e
phase 7: full US coverage — grid regions, datacenters, power plants, backfill, chart perf
- Add 7 new grid regions (BPA, DUKE, SOCO, TVA, FPC, WAPA, NWMT) to cover entire continental US
- Expand datacenters from 108 to 292 facilities across 39 operators
- Add EIA power plant pipeline: download script, 3,546 plants >= 50 MW with diamond map markers
- Rewrite backfill script for 10-year data (2015-07-01) with quarterly/monthly chunking, 3-region parallelism, resumability
- Add materialized views (daily/weekly) with server-side granularity selection for chart performance
- Fix map UX: z-index tooltips, disable POI clicks, move legend via MapControl
2026-02-11 16:08:06 -05:00

93 lines
2.8 KiB
Plaintext

generator client {
provider = "prisma-client"
output = "../src/generated/prisma"
previewFeatures = ["typedSql"]
}
datasource db {
provider = "postgresql"
}
model GridRegion {
id String @id @default(uuid()) @db.Uuid
name String
code String @unique
iso String
boundary Unsupported("geography(MultiPolygon, 4326)")
createdAt DateTime @default(now()) @map("created_at") @db.Timestamptz
datacenters Datacenter[]
electricityPrices ElectricityPrice[]
generationMixes GenerationMix[]
@@map("grid_regions")
}
model Datacenter {
id String @id @default(uuid()) @db.Uuid
name String
operator String
location Unsupported("geography(Point, 4326)")
capacityMw Float @map("capacity_mw")
status String
yearOpened Int @map("year_opened")
regionId String @map("region_id") @db.Uuid
region GridRegion @relation(fields: [regionId], references: [id])
createdAt DateTime @default(now()) @map("created_at") @db.Timestamptz
@@map("datacenters")
}
model ElectricityPrice {
id String @id @default(uuid()) @db.Uuid
regionId String @map("region_id") @db.Uuid
region GridRegion @relation(fields: [regionId], references: [id])
priceMwh Float @map("price_mwh")
demandMw Float @map("demand_mw")
timestamp DateTime @db.Timestamptz
source String
@@unique([regionId, timestamp])
@@index([regionId, timestamp])
@@map("electricity_prices")
}
model CommodityPrice {
id String @id @default(uuid()) @db.Uuid
commodity String
price Float
unit String
timestamp DateTime @db.Timestamptz
source String
@@unique([commodity, timestamp])
@@index([commodity, timestamp])
@@map("commodity_prices")
}
model GenerationMix {
id String @id @default(uuid()) @db.Uuid
regionId String @map("region_id") @db.Uuid
region GridRegion @relation(fields: [regionId], references: [id])
fuelType String @map("fuel_type")
generationMw Float @map("generation_mw")
timestamp DateTime @db.Timestamptz
@@unique([regionId, fuelType, timestamp])
@@index([regionId, timestamp])
@@map("generation_mix")
}
model PowerPlant {
id String @id @default(uuid()) @db.Uuid
plantCode Int @unique @map("plant_code")
name String
operator String
location Unsupported("geography(Point, 4326)")
capacityMw Float @map("capacity_mw")
fuelType String @map("fuel_type")
state String
createdAt DateTime @default(now()) @map("created_at") @db.Timestamptz
@@map("power_plants")
}