openstellaris/prisma/schema.prisma

176 lines
3.9 KiB
Text
Raw Normal View History

2023-12-08 12:26:08 +00:00
generator client {
2023-12-26 01:40:37 +00:00
provider = "cargo prisma"
output = "../backend/src/prisma.rs"
2023-12-08 12:26:08 +00:00
}
datasource db {
provider = "postgresql"
url = env("DATABASE_URL")
}
model Universe {
2023-12-30 09:07:31 +00:00
id Int @id @default(autoincrement())
2023-12-08 12:26:08 +00:00
config Json
2023-12-31 05:33:15 +00:00
players Player[]
empires Empire[]
starSystems StarSystem[]
planets Planet[]
fleets Fleet[]
hyperlanes StarSystemEdges[]
starbases Starbase[]
2023-12-08 12:26:08 +00:00
}
model User {
2023-12-08 23:32:11 +00:00
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())
2023-12-08 12:26:08 +00:00
2023-12-30 09:07:31 +00:00
universeId Int
2023-12-08 12:26:08 +00:00
universe Universe @relation(fields: [universeId], references: [id])
empire Empire?
}
model Empire {
2023-12-31 01:40:47 +00:00
id Int @default(autoincrement())
2023-12-08 12:26:08 +00:00
2023-12-30 09:07:31 +00:00
universeId Int
2023-12-08 23:32:11 +00:00
universe Universe @relation(fields: [universeId], references: [id])
2023-12-08 12:26:08 +00:00
name String
2023-12-31 01:40:47 +00:00
color String
// capitalSystemId Int
// capitalSystem StarSystem @relation("capital", fields: [universeId, capitalSystemId], references: [universeId, index])
2023-12-08 12:26:08 +00:00
2023-12-08 23:32:11 +00:00
playerId String? @unique
player Player? @relation(fields: [playerId], references: [id])
2023-12-31 01:40:47 +00:00
starSystems StarSystem[] @relation("owner")
2023-12-31 05:33:15 +00:00
resources Json
2023-12-31 01:40:47 +00:00
@@id([universeId, id])
2023-12-08 23:32:11 +00:00
}
model StarSystem {
2023-12-30 09:07:31 +00:00
index Int
universeId Int
2023-12-08 23:32:11 +00:00
universe Universe @relation(fields: [universeId], references: [id])
2023-12-30 09:07:31 +00:00
coordX Float
coordY Float
2023-12-08 23:32:11 +00:00
inbound StarSystemEdges[] @relation("inbound")
outbound StarSystemEdges[] @relation("outbound")
2023-12-30 09:07:31 +00:00
2023-12-31 01:40:47 +00:00
ownedByEmpireId Int?
ownedByEmpire Empire? @relation("owner", fields: [universeId, ownedByEmpireId], references: [universeId, id])
2023-12-31 05:33:15 +00:00
planets Planet[]
starbase Starbase?
2023-12-30 09:07:31 +00:00
@@id([universeId, index])
2023-12-08 23:32:11 +00:00
}
model StarSystemEdges {
2023-12-30 09:07:31 +00:00
universeId Int
2023-12-08 23:32:11 +00:00
universe Universe @relation(fields: [universeId], references: [id])
2023-12-30 09:07:31 +00:00
fromSystemId Int
from StarSystem @relation(fields: [universeId, fromSystemId], references: [universeId, index], name: "outbound")
2023-12-08 23:32:11 +00:00
2023-12-30 09:07:31 +00:00
toSystemId Int
to StarSystem @relation(fields: [universeId, toSystemId], references: [universeId, index], name: "inbound")
2023-12-08 23:32:11 +00:00
2023-12-30 05:40:38 +00:00
@@id([universeId, fromSystemId, toSystemId])
2023-12-08 23:32:11 +00:00
}
2023-12-31 05:33:15 +00:00
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])
}
2023-12-08 23:32:11 +00:00
model Planet {
2023-12-31 05:33:15 +00:00
id Int @default(autoincrement())
2023-12-08 23:32:11 +00:00
2023-12-30 09:07:31 +00:00
universeId Int
2023-12-08 23:32:11 +00:00
universe Universe @relation(fields: [universeId], references: [id])
2023-12-31 05:33:15 +00:00
2023-12-31 23:37:01 +00:00
buildings Json
2023-12-31 05:33:15 +00:00
surroundingStarSystemId Int
surroundingStarSystem StarSystem @relation(fields: [universeId, surroundingStarSystemId], references: [universeId, index])
@@id([universeId, id])
2023-12-08 23:32:11 +00:00
}
model Fleet {
id String @id @default(uuid())
2023-12-30 09:07:31 +00:00
universeId Int
2023-12-08 23:32:11 +00:00
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])
2023-12-08 12:26:08 +00:00
}