openstellaris/prisma/schema.prisma
2023-12-25 20:40:37 -05:00

145 lines
3.2 KiB
Text

// This is your Prisma schema file,
// learn more about it in the docs: https://pris.ly/d/prisma-schema
generator client {
// Corresponds to the cargo alias created earlier
provider = "cargo prisma"
// The location to generate the client. Is relative to the position of the schema
output = "../backend/src/prisma.rs"
}
datasource db {
provider = "postgresql"
url = env("DATABASE_URL")
}
model Universe {
id String @id @default(uuid())
config Json
players Player[]
empires Empire[]
starSystems StarSystem[]
planets Planet[]
Fleet Fleet[]
StarSystemEdges StarSystemEdges[]
}
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 String
universe Universe @relation(fields: [universeId], references: [id])
empire Empire?
}
model Empire {
id String @id @default(uuid())
universeId String
universe Universe @relation(fields: [universeId], references: [id])
name String
color String
playerId String? @unique
player Player? @relation(fields: [playerId], references: [id])
}
model StarSystem {
universeId String
universe Universe @relation(fields: [universeId], references: [id])
coordX Int
coordY Int
inbound StarSystemEdges[] @relation("inbound")
outbound StarSystemEdges[] @relation("outbound")
@@id([universeId, coordX, coordY])
}
model StarSystemEdges {
universeId String
universe Universe @relation(fields: [universeId], references: [id])
fromX Int
fromY Int
from StarSystem @relation(fields: [universeId, fromX, fromY], references: [universeId, coordX, coordY], name: "outbound")
toX Int
toY Int
to StarSystem @relation(fields: [universeId, toX, toY], references: [universeId, coordX, coordY], name: "inbound")
@@id([universeId, fromX, fromY, toX, toY])
}
model Planet {
id String @id @default(uuid())
universeId String
universe Universe @relation(fields: [universeId], references: [id])
}
model Fleet {
id String @id @default(uuid())
universeId String
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])
}