Fixed prisma schema file
This commit is contained in:
parent
0b6167ed4b
commit
28e6a556f8
85
prisma/schema.prisma
Normal file
85
prisma/schema.prisma
Normal file
@ -0,0 +1,85 @@
|
|||||||
|
// Datasource configuration
|
||||||
|
datasource db {
|
||||||
|
provider = "sqlserver"
|
||||||
|
url = env("DATABASE_URL")
|
||||||
|
}
|
||||||
|
|
||||||
|
// User model
|
||||||
|
model User {
|
||||||
|
id Int @id @default(autoincrement())
|
||||||
|
createdAt DateTime @default(now())
|
||||||
|
name String
|
||||||
|
email String @unique
|
||||||
|
passwordHash String
|
||||||
|
role String @default("GUEST") @db.VarChar(10) // ADMIN, SCIENTIST, GUEST
|
||||||
|
scientist Scientist? @relation
|
||||||
|
purchasedArtefacts Artefact[] @relation("UserPurchasedArtefacts")
|
||||||
|
}
|
||||||
|
|
||||||
|
// Scientist model
|
||||||
|
model Scientist {
|
||||||
|
id Int @id @default(autoincrement())
|
||||||
|
createdAt DateTime @default(now())
|
||||||
|
name String
|
||||||
|
level String @db.VarChar(10) // JUNIOR, SENIOR
|
||||||
|
user User @relation(fields: [userId], references: [id])
|
||||||
|
userId Int @unique
|
||||||
|
superior Scientist? @relation("SuperiorRelation", fields: [superiorId], references: [id], onDelete: NoAction, onUpdate: NoAction)
|
||||||
|
superiorId Int?
|
||||||
|
subordinates Scientist[] @relation("SuperiorRelation")
|
||||||
|
earthquakes Earthquake[] @relation("ScientistEarthquakeCreator")
|
||||||
|
observatories Observatory[] @relation("ScientistObservatoryCreator")
|
||||||
|
artefacts Artefact[] @relation("ScientistArtefactCreator")
|
||||||
|
}
|
||||||
|
|
||||||
|
// Earthquake model
|
||||||
|
model Earthquake {
|
||||||
|
id Int @id @default(autoincrement())
|
||||||
|
createdAt DateTime @default(now())
|
||||||
|
updatedAt DateTime @updatedAt
|
||||||
|
date DateTime
|
||||||
|
location String
|
||||||
|
latitude String
|
||||||
|
longitude String
|
||||||
|
magnitude Float
|
||||||
|
depth Float
|
||||||
|
creatorId Int?
|
||||||
|
creator Scientist? @relation("ScientistEarthquakeCreator", fields: [creatorId], references: [id], onDelete: NoAction, onUpdate: NoAction)
|
||||||
|
artefacts Artefact[]
|
||||||
|
observatories Observatory[] @relation("EarthquakeObservatory")
|
||||||
|
}
|
||||||
|
|
||||||
|
// Observatory model
|
||||||
|
model Observatory {
|
||||||
|
id Int @id @default(autoincrement())
|
||||||
|
createdAt DateTime @default(now())
|
||||||
|
updatedAt DateTime @updatedAt
|
||||||
|
name String
|
||||||
|
location String
|
||||||
|
longitude String
|
||||||
|
latitude String
|
||||||
|
dateEstablished Int?
|
||||||
|
functional Boolean
|
||||||
|
seismicSensorOnline Boolean @default(true)
|
||||||
|
creatorId Int?
|
||||||
|
creator Scientist? @relation("ScientistObservatoryCreator", fields: [creatorId], references: [id], onDelete: NoAction, onUpdate: NoAction)
|
||||||
|
earthquakes Earthquake[] @relation("EarthquakeObservatory")
|
||||||
|
}
|
||||||
|
|
||||||
|
// Artefact model
|
||||||
|
model Artefact {
|
||||||
|
id Int @id @default(autoincrement())
|
||||||
|
createdAt DateTime @default(now())
|
||||||
|
updatedAt DateTime @updatedAt
|
||||||
|
type String @db.VarChar(50) // Lava, Tephra, Ash, Soil
|
||||||
|
warehouseArea String // Examples: "ZoneA-Shelf1", "ZoneB-Rack2", "ZoneC-Bin3"
|
||||||
|
earthquakeId Int
|
||||||
|
earthquake Earthquake @relation(fields: [earthquakeId], references: [id])
|
||||||
|
creatorId Int?
|
||||||
|
creator Scientist? @relation("ScientistArtefactCreator", fields: [creatorId], references: [id], onDelete: NoAction, onUpdate: NoAction)
|
||||||
|
required Boolean @default(true)
|
||||||
|
shopPrice Float? // In Euros
|
||||||
|
purchasedById Int?
|
||||||
|
purchasedBy User? @relation("UserPurchasedArtefacts", fields: [purchasedById], references: [id], onDelete: NoAction, onUpdate: NoAction)
|
||||||
|
pickedUp Boolean @default(false)
|
||||||
|
}
|
||||||
@ -1,85 +0,0 @@
|
|||||||
// Datasource configuration
|
|
||||||
datasource db {
|
|
||||||
provider = "sqlserver"
|
|
||||||
url = env("DATABASE_URL")
|
|
||||||
}
|
|
||||||
|
|
||||||
// User model
|
|
||||||
model User {
|
|
||||||
id Int @id @default(autoincrement())
|
|
||||||
createdAt DateTime @default(now())
|
|
||||||
name String
|
|
||||||
email String @unique
|
|
||||||
passwordHash String
|
|
||||||
role String @default("GUEST") @db.VarChar(10) // ADMIN, SCIENTIST, GUEST
|
|
||||||
scientist Scientist? @relation
|
|
||||||
purchasedArtifacts Artifact[] @relation("UserPurchasedArtifacts")
|
|
||||||
}
|
|
||||||
|
|
||||||
// Scientist model
|
|
||||||
model Scientist {
|
|
||||||
id Int @id @default(autoincrement())
|
|
||||||
createdAt DateTime @default(now())
|
|
||||||
name String
|
|
||||||
level String @db.VarChar(10) // JUNIOR, SENIOR
|
|
||||||
user User @relation(fields: [userId], references: [id])
|
|
||||||
userId Int @unique
|
|
||||||
superior Scientist? @relation("SuperiorRelation", fields: [superiorId], references: [id], onDelete: NoAction, onUpdate: NoAction)
|
|
||||||
superiorId Int?
|
|
||||||
subordinates Scientist[] @relation("SuperiorRelation")
|
|
||||||
earthquakes Earthquake[] @relation("ScientistEarthquakeCreator")
|
|
||||||
observatories Observatory[] @relation("ScientistObservatoryCreator")
|
|
||||||
artifacts Artifact[] @relation("ScientistArtifactCreator")
|
|
||||||
}
|
|
||||||
|
|
||||||
// Earthquake model
|
|
||||||
model Earthquake {
|
|
||||||
id Int @id @default(autoincrement())
|
|
||||||
createdAt DateTime @default(now())
|
|
||||||
updatedAt DateTime @updatedAt
|
|
||||||
date DateTime
|
|
||||||
locaiton String
|
|
||||||
latitude String
|
|
||||||
longitude String
|
|
||||||
magnitude Float
|
|
||||||
depth Float
|
|
||||||
creatorId Int?
|
|
||||||
creator Scientist? @relation("ScientistEarthquakeCreator", fields: [creatorId], references: [id], onDelete: NoAction, onUpdate: NoAction)
|
|
||||||
artifacts Artifact[]
|
|
||||||
observatories Observatory[] @relation("EarthquakeObservatory")
|
|
||||||
}
|
|
||||||
|
|
||||||
// Observatory model
|
|
||||||
model Observatory {
|
|
||||||
id Int @id @default(autoincrement())
|
|
||||||
createdAt DateTime @default(now())
|
|
||||||
updatedAt DateTime @updatedAt
|
|
||||||
name String
|
|
||||||
location String
|
|
||||||
longitude String
|
|
||||||
latitude String
|
|
||||||
dateEstablished Int?
|
|
||||||
functional Boolean
|
|
||||||
seismicSensorOnline Boolean @default(true)
|
|
||||||
creatorId Int?
|
|
||||||
creator Scientist? @relation("ScientistObservatoryCreator", fields: [creatorId], references: [id], onDelete: NoAction, onUpdate: NoAction)
|
|
||||||
earthquakes Earthquake[] @relation("EarthquakeObservatory")
|
|
||||||
}
|
|
||||||
|
|
||||||
// Artifact model
|
|
||||||
model Artifact {
|
|
||||||
id Int @id @default(autoincrement())
|
|
||||||
createdAt DateTime @default(now())
|
|
||||||
updatedAt DateTime @updatedAt
|
|
||||||
type String @db.VarChar(50) // Lava, Tephra, Ash, Soil
|
|
||||||
warehouseArea String // Examples: "ZoneA-Shelf1", "ZoneB-Rack2", "ZoneC-Bin3"
|
|
||||||
earthquakeId Int
|
|
||||||
earthquake Earthquake @relation(fields: [earthquakeId], references: [id])
|
|
||||||
creatorId Int?
|
|
||||||
creator Scientist? @relation("ScientistArtifactCreator", fields: [creatorId], references: [id], onDelete: NoAction, onUpdate: NoAction)
|
|
||||||
required Boolean @default(true)
|
|
||||||
shopPrice Float? // In Euros
|
|
||||||
purchasedById Int?
|
|
||||||
purchasedBy User? @relation("UserPurchasedArtifacts", fields: [purchasedById], references: [id], onDelete: NoAction, onUpdate: NoAction)
|
|
||||||
pickedUp Boolean @default(false)
|
|
||||||
}
|
|
||||||
Loading…
x
Reference in New Issue
Block a user