Added basic prisma schema
This commit is contained in:
9 files changed
+140
-9
No files matched your search
@@ -1,8 +0,0 @@
|
|||||||
# Environment variables declared in this file are NOT automatically loaded by Prisma.
|
|
||||||
# Please add `import "dotenv/config";` to your `prisma7.config.ts` file, or use the Prisma CLI with Bun
|
|
||||||
# to load environment variables from .env files: https://pris.ly/prisma-config-env-vars.
|
|
||||||
|
|
||||||
# Prisma supports the native connection string format for PostgreSQL, MySQL, SQLite, SQL Server, MongoDB and CockroachDB.
|
|
||||||
# See the documentation for all the connection string options: https://pris.ly/d/connection-strings
|
|
||||||
|
|
||||||
DATABASE_URL="postgresql://johndoe:randompassword@localhost:5432/mydb?schema=public"
|
|
||||||
@@ -41,3 +41,4 @@ yarn-error.log*
|
|||||||
package-lock.json
|
package-lock.json
|
||||||
**/*.bun
|
**/*.bun
|
||||||
/generated/prisma
|
/generated/prisma
|
||||||
|
/.idea/dataSources.xml
|
||||||
@@ -0,0 +1,31 @@
|
|||||||
|
model CarBrand {
|
||||||
|
id Int @id @default(autoincrement())
|
||||||
|
|
||||||
|
name String
|
||||||
|
carModels CarModel[]
|
||||||
|
}
|
||||||
|
|
||||||
|
model CarModel {
|
||||||
|
id Int @id @default(autoincrement())
|
||||||
|
|
||||||
|
name String
|
||||||
|
|
||||||
|
carBrandId Int
|
||||||
|
brand CarBrand @relation(fields: [carBrandId], references: [id])
|
||||||
|
cars Car[]
|
||||||
|
}
|
||||||
|
|
||||||
|
model Car {
|
||||||
|
id Int @id @default(autoincrement())
|
||||||
|
|
||||||
|
licensePlate String
|
||||||
|
productionYear Int
|
||||||
|
|
||||||
|
carModelId Int
|
||||||
|
model CarModel @relation(fields: [carModelId], references: [id])
|
||||||
|
|
||||||
|
customerId Int
|
||||||
|
customer Customer @relation(fields: [customerId], references: [id])
|
||||||
|
|
||||||
|
workOrders WorkOrder[]
|
||||||
|
}
|
||||||
@@ -0,0 +1,9 @@
|
|||||||
|
model Customer {
|
||||||
|
id Int @id @default(autoincrement())
|
||||||
|
|
||||||
|
name String
|
||||||
|
email String
|
||||||
|
phone String
|
||||||
|
|
||||||
|
cars Car[]
|
||||||
|
}
|
||||||
@@ -0,0 +1,8 @@
|
|||||||
|
model Invoice {
|
||||||
|
workOrderId Int @unique
|
||||||
|
workOrder WorkOrder @relation(fields: [workOrderId], references: [id])
|
||||||
|
|
||||||
|
total Int
|
||||||
|
|
||||||
|
paidDate DateTime?
|
||||||
|
}
|
||||||
@@ -0,0 +1,27 @@
|
|||||||
|
model Mechanic {
|
||||||
|
id Int @id @default(autoincrement())
|
||||||
|
|
||||||
|
name String
|
||||||
|
hourlyRate Int
|
||||||
|
|
||||||
|
skills MechanicToSkill[]
|
||||||
|
workOrders WorkOrderToMechanic[]
|
||||||
|
}
|
||||||
|
|
||||||
|
model MechanicToSkill {
|
||||||
|
mechanicId Int
|
||||||
|
mechanic Mechanic @relation(fields: [mechanicId], references: [id])
|
||||||
|
|
||||||
|
skillId Int
|
||||||
|
skill MechanicSkill @relation(fields: [skillId], references: [id])
|
||||||
|
|
||||||
|
@@id([mechanicId, skillId])
|
||||||
|
}
|
||||||
|
|
||||||
|
model MechanicSkill {
|
||||||
|
id Int @id @default(autoincrement())
|
||||||
|
|
||||||
|
name String
|
||||||
|
|
||||||
|
mechanics MechanicToSkill[]
|
||||||
|
}
|
||||||
@@ -0,0 +1,29 @@
|
|||||||
|
model SparePart {
|
||||||
|
id Int @id @default(autoincrement())
|
||||||
|
|
||||||
|
name String
|
||||||
|
partNumber String
|
||||||
|
|
||||||
|
supplierId Int
|
||||||
|
supplier Supplier @relation(fields: [supplierId], references: [id])
|
||||||
|
workOrderToSpareParts WorkOrderToSparePart[]
|
||||||
|
}
|
||||||
|
|
||||||
|
model Supplier {
|
||||||
|
id Int @id @default(autoincrement())
|
||||||
|
|
||||||
|
name String
|
||||||
|
spareParts SparePart[]
|
||||||
|
}
|
||||||
|
|
||||||
|
model WorkOrderToSparePart {
|
||||||
|
sparePartId Int
|
||||||
|
sparePart SparePart @relation(fields: [sparePartId], references: [id])
|
||||||
|
workOrderId Int
|
||||||
|
workOrder WorkOrder @relation(fields: [workOrderId], references: [id])
|
||||||
|
|
||||||
|
quantity Int
|
||||||
|
pricePerUnit Int
|
||||||
|
|
||||||
|
@@id([sparePartId, workOrderId])
|
||||||
|
}
|
||||||
@@ -0,0 +1,34 @@
|
|||||||
|
enum WorkOrderStatus {
|
||||||
|
OPEN
|
||||||
|
IN_PROGRESS
|
||||||
|
DONE
|
||||||
|
}
|
||||||
|
|
||||||
|
model WorkOrder {
|
||||||
|
id Int @id @default(autoincrement())
|
||||||
|
|
||||||
|
currentMileage Int
|
||||||
|
problem String
|
||||||
|
|
||||||
|
carId Int
|
||||||
|
car Car @relation(fields: [carId], references: [id])
|
||||||
|
|
||||||
|
mechanics WorkOrderToMechanic[]
|
||||||
|
sparePart WorkOrderToSparePart[]
|
||||||
|
|
||||||
|
invoice Invoice?
|
||||||
|
status WorkOrderStatus @default(OPEN)
|
||||||
|
|
||||||
|
createdAt DateTime @default(now())
|
||||||
|
}
|
||||||
|
|
||||||
|
model WorkOrderToMechanic {
|
||||||
|
mechanicId Int
|
||||||
|
mechanic Mechanic @relation(fields: [mechanicId], references: [id])
|
||||||
|
workOrderId Int
|
||||||
|
workOrder WorkOrder @relation(fields: [workOrderId], references: [id])
|
||||||
|
|
||||||
|
minutesWorked Int
|
||||||
|
|
||||||
|
@@id([mechanicId, workOrderId])
|
||||||
|
}
|
||||||
+1
-1
@@ -2,7 +2,7 @@
|
|||||||
import { defineConfig, env } from "prisma/config";
|
import { defineConfig, env } from "prisma/config";
|
||||||
|
|
||||||
export default defineConfig({
|
export default defineConfig({
|
||||||
schema: "prisma/schema.prisma",
|
schema: "prisma",
|
||||||
migrations: {
|
migrations: {
|
||||||
path: "prisma/migrations",
|
path: "prisma/migrations",
|
||||||
},
|
},
|
||||||
|
|||||||
Reference in new issue
Block a user