// This is your Prisma schema file, // learn more about it in the docs: https://pris.ly/d/prisma-schema generator client { provider = "prisma-client-js" } datasource db { provider = "sqlite" url = "file:./dev.db" } model Bike { id String @id @default(cuid()) name String brand String? model String? purchaseDate DateTime? notes String? wearParts WearPart[] createdAt DateTime @default(now()) updatedAt DateTime @updatedAt } model WearPart { id String @id @default(cuid()) bikeId String bike Bike @relation(fields: [bikeId], references: [id], onDelete: Cascade) type String // CHAIN, BRAKE_PADS, TIRE, CASSETTE, CHAINRING, DERAILLEUR, etc. brand String? model String? installDate DateTime installMileage Int @default(0) serviceInterval Int // in km status String @default("ACTIVE") // ACTIVE, NEEDS_SERVICE, REPLACED, INACTIVE cost Float? notes String? maintenanceHistory MaintenanceHistory[] createdAt DateTime @default(now()) updatedAt DateTime @updatedAt } model MaintenanceHistory { id String @id @default(cuid()) wearPartId String wearPart WearPart @relation(fields: [wearPartId], references: [id], onDelete: Cascade) date DateTime mileage Int action String // INSTALL, REPLACE, SERVICE, CHECK, ADJUST notes String? cost Float? createdAt DateTime @default(now()) updatedAt DateTime @updatedAt }