Created
September 17, 2024 06:01
-
-
Save Vetrivel-VP/675df119058f03bd92e85b4371328393 to your computer and use it in GitHub Desktop.
Used Cars & Bikes Hub with Next.js & Prisma - Contact Owners Directly! πποΈ
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// This is your Prisma schema file, | |
// learn more about it in the docs: https://pris.ly/d/prisma-schema | |
// Looking for ways to speed up your queries, or scale easily with your serverless or edge functions? | |
// Try Prisma Accelerate: https://pris.ly/cli/accelerate-init | |
generator client { | |
provider = "prisma-client-js" | |
} | |
datasource db { | |
provider = "sqlite" | |
url = env("DATABASE_URL") | |
} | |
model User { | |
id String @id // Changed to String with UUID | |
email String @unique | |
name String? | |
contact String? | |
address String? | |
location String? | |
profileImage String? | |
role String @default("user") // Using a string instead of enum | |
vehicles Vehicle[] // One-to-many relationship with Vehicles | |
blogs Blog[] // One-to-many relationship with Blogs | |
notifications Notification[] // One-to-many relationship with Notifications | |
createdAt DateTime @default(now()) | |
updatedAt DateTime @updatedAt | |
} | |
model Vehicle { | |
id String @id @default(uuid()) | |
make String | |
model String | |
year Int | |
price Float | |
categoryId String | |
subCategoryId String | |
ownerId String | |
owner User @relation(fields: [ownerId], references: [id]) | |
category Category @relation(fields: [categoryId], references: [id]) | |
subCategory SubCategory @relation(fields: [subCategoryId], references: [id]) | |
coverImage String // Primary image URL | |
images String @default("[]") // Store as JSON array | |
status String @default("pending") | |
report String @default("low-mileage") | |
location String | |
notifications Notification[] | |
createdAt DateTime @default(now()) | |
updatedAt DateTime @updatedAt | |
@@index([make]) | |
} | |
model Category { | |
id String @id @default(uuid()) // Changed to String with UUID | |
name String | |
slug String @unique // Slug field added, must be unique | |
subCategories SubCategory[] // One-to-many relationship with SubCategories | |
vehicles Vehicle[] // One-to-many relationship with Vehicles | |
} | |
model SubCategory { | |
id String @id @default(uuid()) // Changed to String with UUID | |
name String | |
slug String @unique // Slug field added, must be unique | |
categoryId String // Foreign key type changed to String | |
category Category @relation(fields: [categoryId], references: [id]) | |
vehicles Vehicle[] // One-to-many relationship with Vehicles | |
} | |
model Blog { | |
id String @id @default(uuid()) // Changed to String with UUID | |
title String | |
content String | |
coverImage String | |
authorId String // Foreign key type changed to String | |
author User @relation(fields: [authorId], references: [id]) | |
status String @default("pending") // Using a string instead of enum | |
notifications Notification[] // One-to-many relationship with Notifications | |
createdAt DateTime @default(now()) | |
updatedAt DateTime @updatedAt | |
@@index([title]) | |
} | |
model Notification { | |
id String @id @default(uuid()) // Changed to String with UUID | |
message String | |
userId String // Foreign key type changed to String | |
user User @relation(fields: [userId], references: [id]) | |
// New fields | |
type String // This could be "blog" or "vehicle" | |
status String @default("pending") // Notification status, default to pending | |
// Optional relation fields for either blog or vehicle notifications | |
blogId String? // Foreign key type changed to String and made optional | |
blog Blog? @relation(fields: [blogId], references: [id]) | |
vehicleId String? // Foreign key type changed to String and made optional | |
vehicle Vehicle? @relation(fields: [vehicleId], references: [id]) | |
createdAt DateTime @default(now()) | |
updatedAt DateTime @updatedAt | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment