prisma schema file working (hopefully)
This commit is contained in:
parent
ce30fb1ed7
commit
f4d06df112
1573
EarthquakeEvents.txt
Normal file
1573
EarthquakeEvents.txt
Normal file
File diff suppressed because it is too large
Load Diff
@ -1,8 +1,10 @@
|
||||
// Datasource configuration
|
||||
datasource db {
|
||||
provider = "sqlserver"
|
||||
url = env("DATABASE_URL")
|
||||
}
|
||||
|
||||
// User model
|
||||
model User {
|
||||
id Int @id @default(autoincrement())
|
||||
createdAt DateTime @default(now())
|
||||
@ -10,36 +12,56 @@ model User {
|
||||
passwordHash String
|
||||
firstname String
|
||||
surname String
|
||||
// pfpUrl String
|
||||
role Role @default(USER)
|
||||
role String @default("USER") @db.VarChar(10)
|
||||
scientist Scientist? @relation // Optional relation to Scientist
|
||||
}
|
||||
|
||||
// Earthquake model
|
||||
model Earthquake {
|
||||
id Int @id @default(autoincrement())
|
||||
createdAt DateTime @default(now())
|
||||
updatedAt DateTime @updatedAt
|
||||
code String @unique
|
||||
name String @db.VarChar(255)
|
||||
date DateTime
|
||||
location String
|
||||
longitude String
|
||||
latitude String
|
||||
magnitude Float
|
||||
depth Float
|
||||
casualties Int
|
||||
|
||||
creator User? @relation(fields: [creatorId], references: [id])
|
||||
creatorId Int?
|
||||
|
||||
observatory Observatory? @relation(fields: [observatoryId], references: [id])
|
||||
observatoryId Int?
|
||||
creatorId Int? // Creator's ID (Foreign Key referencing Scientist)
|
||||
creator Scientist? @relation("ScientistEarthquakeCreator", fields: [creatorId], references: [id], onDelete: NoAction, onUpdate: NoAction) // Points back to Scientist
|
||||
}
|
||||
|
||||
// Observatory model
|
||||
model Observatory {
|
||||
id Int @id @default(autoincrement())
|
||||
createdAt DateTime @default(now())
|
||||
updatedAt DateTime @updatedAt
|
||||
name String @db.VarChar(255)
|
||||
location String
|
||||
longitude String
|
||||
latitude String
|
||||
dateEstablished Int?
|
||||
functional Boolean
|
||||
description String? @db.Text
|
||||
creatorId Int? // Creator's ID (Foreign Key referencing Scientist)
|
||||
creator Scientist? @relation("ScientistObservatoryCreator", fields: [creatorId], references: [id], onDelete: NoAction, onUpdate: NoAction) // Points back to Scientist
|
||||
}
|
||||
|
||||
enum Role {
|
||||
USER
|
||||
ADMIN
|
||||
// Scientist model
|
||||
model Scientist {
|
||||
id Int @id @default(autoincrement())
|
||||
name String
|
||||
createdAt DateTime @default(now())
|
||||
level String @db.VarChar(10) // Junior or Senior
|
||||
user User @relation(fields: [userId], references: [id]) // Relates to the User model
|
||||
userId Int @unique
|
||||
|
||||
// Self-referencing relation: superior and subordinates
|
||||
superior Scientist? @relation("SuperiorRelation", fields: [superiorId], references: [id], onDelete: NoAction, onUpdate: NoAction) // Parent scientist
|
||||
superiorId Int?
|
||||
subordinates Scientist[] @relation("SuperiorRelation") // Scientists who view this one as a superior
|
||||
|
||||
// Earthquake and Observatory relations
|
||||
earthquakes Earthquake[] @relation("ScientistEarthquakeCreator") // Scientists can create earthquakes
|
||||
observatories Observatory[] @relation("ScientistObservatoryCreator") // Scientists can create observatories
|
||||
}
|
||||
Loading…
x
Reference in New Issue
Block a user