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,45 +1,67 @@
|
|||||||
|
// Datasource configuration
|
||||||
datasource db {
|
datasource db {
|
||||||
provider = "sqlserver"
|
provider = "sqlserver"
|
||||||
url = env("DATABASE_URL")
|
url = env("DATABASE_URL")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// User model
|
||||||
model User {
|
model User {
|
||||||
id Int @id @default(autoincrement())
|
id Int @id @default(autoincrement())
|
||||||
createdAt DateTime @default(now())
|
createdAt DateTime @default(now())
|
||||||
email String @unique
|
email String @unique
|
||||||
passwordHash String
|
passwordHash String
|
||||||
firstname String
|
firstname String
|
||||||
surname String
|
surname String
|
||||||
// pfpUrl String
|
role String @default("USER") @db.VarChar(10)
|
||||||
role Role @default(USER)
|
scientist Scientist? @relation // Optional relation to Scientist
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Earthquake model
|
||||||
model Earthquake {
|
model Earthquake {
|
||||||
id Int @id @default(autoincrement())
|
id Int @id @default(autoincrement())
|
||||||
createdAt DateTime @default(now())
|
createdAt DateTime @default(now())
|
||||||
updatedAt DateTime @updatedAt
|
updatedAt DateTime @updatedAt
|
||||||
code String @unique
|
name String @db.VarChar(255)
|
||||||
name String @db.VarChar(255)
|
date DateTime
|
||||||
date DateTime
|
location String
|
||||||
location String
|
magnitude Float
|
||||||
longitude String
|
depth Float
|
||||||
latitude String
|
casualties Int
|
||||||
magnitude Float
|
creatorId Int? // Creator's ID (Foreign Key referencing Scientist)
|
||||||
depth Float
|
creator Scientist? @relation("ScientistEarthquakeCreator", fields: [creatorId], references: [id], onDelete: NoAction, onUpdate: NoAction) // Points back to Scientist
|
||||||
casualties Int
|
|
||||||
|
|
||||||
creator User? @relation(fields: [creatorId], references: [id])
|
|
||||||
creatorId Int?
|
|
||||||
|
|
||||||
observatory Observatory? @relation(fields: [observatoryId], references: [id])
|
|
||||||
observatoryId Int?
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Observatory model
|
||||||
model Observatory {
|
model Observatory {
|
||||||
id Int @id @default(autoincrement())
|
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 {
|
// Scientist model
|
||||||
USER
|
model Scientist {
|
||||||
ADMIN
|
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