175 lines
3.9 KiB
Text
175 lines
3.9 KiB
Text
generator client {
|
|
provider = "cargo prisma"
|
|
output = "../backend/src/prisma.rs"
|
|
}
|
|
|
|
datasource db {
|
|
provider = "postgresql"
|
|
url = env("DATABASE_URL")
|
|
}
|
|
|
|
model Universe {
|
|
id Int @id @default(autoincrement())
|
|
|
|
config Json
|
|
|
|
players Player[]
|
|
empires Empire[]
|
|
starSystems StarSystem[]
|
|
planets Planet[]
|
|
fleets Fleet[]
|
|
hyperlanes StarSystemEdges[]
|
|
starbases Starbase[]
|
|
}
|
|
|
|
model User {
|
|
id String @id @default(uuid())
|
|
email String? @unique
|
|
emailVerified DateTime?
|
|
name String
|
|
image String?
|
|
|
|
accounts Account[]
|
|
sessions Session[]
|
|
}
|
|
|
|
model Player {
|
|
id String @id @default(uuid())
|
|
|
|
universeId Int
|
|
universe Universe @relation(fields: [universeId], references: [id])
|
|
|
|
empire Empire?
|
|
}
|
|
|
|
model Empire {
|
|
id Int @default(autoincrement())
|
|
|
|
universeId Int
|
|
universe Universe @relation(fields: [universeId], references: [id])
|
|
|
|
name String
|
|
color String
|
|
|
|
// capitalSystemId Int
|
|
// capitalSystem StarSystem @relation("capital", fields: [universeId, capitalSystemId], references: [universeId, index])
|
|
|
|
playerId String? @unique
|
|
player Player? @relation(fields: [playerId], references: [id])
|
|
|
|
starSystems StarSystem[] @relation("owner")
|
|
|
|
resources Json
|
|
|
|
@@id([universeId, id])
|
|
}
|
|
|
|
model StarSystem {
|
|
index Int
|
|
universeId Int
|
|
universe Universe @relation(fields: [universeId], references: [id])
|
|
|
|
coordX Float
|
|
coordY Float
|
|
|
|
inbound StarSystemEdges[] @relation("inbound")
|
|
outbound StarSystemEdges[] @relation("outbound")
|
|
|
|
ownedByEmpireId Int?
|
|
ownedByEmpire Empire? @relation("owner", fields: [universeId, ownedByEmpireId], references: [universeId, id])
|
|
|
|
planets Planet[]
|
|
starbase Starbase?
|
|
|
|
@@id([universeId, index])
|
|
}
|
|
|
|
model StarSystemEdges {
|
|
universeId Int
|
|
universe Universe @relation(fields: [universeId], references: [id])
|
|
|
|
fromSystemId Int
|
|
from StarSystem @relation(fields: [universeId, fromSystemId], references: [universeId, index], name: "outbound")
|
|
|
|
toSystemId Int
|
|
to StarSystem @relation(fields: [universeId, toSystemId], references: [universeId, index], name: "inbound")
|
|
|
|
@@id([universeId, fromSystemId, toSystemId])
|
|
}
|
|
|
|
model Starbase {
|
|
id Int @default(autoincrement())
|
|
|
|
universeId Int
|
|
universe Universe @relation(fields: [universeId], references: [id])
|
|
|
|
starSystemId Int
|
|
starSystem StarSystem @relation(fields: [universeId, starSystemId], references: [universeId, index])
|
|
|
|
@@id([universeId, id])
|
|
@@unique([universeId, starSystemId])
|
|
}
|
|
|
|
model Planet {
|
|
id Int @default(autoincrement())
|
|
|
|
universeId Int
|
|
universe Universe @relation(fields: [universeId], references: [id])
|
|
|
|
buildings Json
|
|
|
|
surroundingStarSystemId Int
|
|
surroundingStarSystem StarSystem @relation(fields: [universeId, surroundingStarSystemId], references: [universeId, index])
|
|
|
|
@@id([universeId, id])
|
|
}
|
|
|
|
model Fleet {
|
|
id String @id @default(uuid())
|
|
|
|
universeId Int
|
|
universe Universe @relation(fields: [universeId], references: [id])
|
|
}
|
|
|
|
model Technology {
|
|
name String @id
|
|
description String
|
|
effects Json
|
|
}
|
|
|
|
// SvelteKit Auth
|
|
|
|
model Account {
|
|
id String @id @default(cuid())
|
|
userId String
|
|
type String
|
|
provider String
|
|
providerAccountId String
|
|
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])
|
|
}
|
|
|
|
model Session {
|
|
id String @id @default(cuid())
|
|
sessionToken String @unique
|
|
userId String
|
|
expires DateTime
|
|
user User @relation(fields: [userId], references: [id], onDelete: Cascade)
|
|
}
|
|
|
|
model VerificationToken {
|
|
identifier String
|
|
token String @unique
|
|
expires DateTime
|
|
|
|
@@unique([identifier, token])
|
|
}
|