generator client { provider = "prisma-client-js" binaryTargets = ["native", "rhel-openssl-1.1.x"] } datasource db { provider = "mysql" url = env("DATABASE_URL") } model UserRole { id BigInt @id @default(autoincrement()) roleName String? @map("role_name") @db.VarChar(50) roleSlug String? @map("role_slug") @db.VarChar(100) status Int? createdAt DateTime? @default(now()) @map("created_at") @db.Timestamp(0) updatedAt DateTime? @updatedAt @map("updated_at") @db.Timestamp(0) tutorials Tutorial[] advertisements Advertisement[] cancellationReasons CancellationReason[] categorySubCategorySetups CategorySubCategorySetup[] helperInterns HelperIntern[] profileUpdateRequests ProfileUpdateRequest[] ratingReasons RatingReason[] skillSets SkillSet[] userAddresses UserAddress[] vehicles VehicleMaster[] gigs Gig[] gigProviderRequests GigProviderRequest[] userEarnings UserEarning[] settlements Settlement[] serviceCartProviders ServiceCart[] @relation("ServiceCartProviderRole") originalProviderGrievances Grievance[] @relation("GrievanceOriginalRole") assignedProviderGrievances Grievance[] @relation("GrievanceAssignedRole") raisedGrievances Grievance[] @relation("GrievanceRaisedRole") facilityRatings OrderFacilityRating[] sellerRatings SellerRating[] productRatings ProductRating[] @@map("cg_tbl_user_roles") } model Customer { id BigInt @id @default(autoincrement()) fullName String? @map("full_name") @db.VarChar(100) mobile String? @db.VarChar(255) email String? @db.VarChar(255) profilePhotoFile String? @map("profile_photo_file") @db.VarChar(255) status Int? createdAt DateTime? @default(now()) @map("created_at") @db.Timestamp(0) updatedAt DateTime? @updatedAt @map("updated_at") @db.Timestamp(0) dateOfBirth DateTime? @map("date_of_birth") @db.Date fcmToken String? @map("fcm_token") @db.Text marriageDate DateTime? @map("marriage_date") @db.Date refCode String? @unique @map("ref_code") @db.VarChar(100) referredBy BigInt? @map("referred_by") @@map("cg_tbl_customers") } model HelperIntern { id BigInt @id @default(autoincrement()) roleId BigInt? @map("role_id") firstName String? @map("first_name") @db.VarChar(100) lastName String? @map("last_name") @db.VarChar(100) mobile String? @db.VarChar(20) email String? @db.VarChar(150) languageIds String? @map("language_ids") @db.LongText bloodGroup String? @map("blood_group") @db.VarChar(20) aadhaarNumber String? @map("aadhaar_number") @db.VarChar(20) panNumber String? @map("pan_number") @db.VarChar(20) cinNumber String? @map("cin_number") @db.VarChar(50) dob DateTime? @map("dob") @db.Date address String? @db.Text state String? @db.VarChar(100) city String? @db.VarChar(100) zone String? @db.LongText pincode String? @db.VarChar(10) countryCode String? @map("country_code") @db.VarChar(10) bankName String? @map("bank_name") @db.VarChar(150) bankAccountNumber String? @map("bank_account_number") @db.VarChar(50) bankIfscCode String? @map("bank_ifsc_code") @db.VarChar(20) skills String? @db.LongText emergencyContactName String? @map("emergency_contact_name") @db.VarChar(100) emergencyContactNumber String? @map("emergency_contact_number") @db.VarChar(20) relationship String? @db.VarChar(50) panCardFile String? @map("pan_card_file") @db.VarChar(255) gstFile String? @map("gst_file") @db.VarChar(255) cinFile String? @map("cin_file") @db.VarChar(255) bankDocumentFile String? @map("bank_document_file") @db.VarChar(255) aadhaarCardFile String? @map("aadhaar_card_file") @db.VarChar(255) profilePhotoFile String? @map("profile_photo_file") @db.VarChar(255) educationCertificateFile String? @map("education_certificate_file") @db.VarChar(255) policeVerificationFile String? @map("police_verification_file") @db.VarChar(255) status Int? @default(0) isVerified Int? @map("is_verified") createdAt DateTime? @default(now()) @map("created_at") @db.Timestamp(0) updatedAt DateTime? @updatedAt @map("updated_at") @db.Timestamp(0) averageRating Decimal? @default(0.00) @map("avg_rating") @db.Decimal(3, 2) ratingsCount Int @default(0) @map("ratings_count") fcmToken String? @map("fcm_token") @db.Text helperInternId String @unique @map("helper_intern_id") @db.VarChar(100) latitude Decimal? @db.Decimal(10, 8) longitude Decimal? @db.Decimal(11, 8) role UserRole? @relation(fields: [roleId], references: [id], onDelete: NoAction, onUpdate: NoAction) @@index([roleId], map: "cg_tbl_helper_interns_role_id_fkey") @@map("cg_tbl_helper_interns") } model PhoneVerification { id BigInt @id @default(autoincrement()) mobile String @db.VarChar(20) otpCode String @map("otp_code") @db.VarChar(10) expiresAt DateTime @default(now()) @map("expires_at") @db.Timestamp(0) createdAt DateTime? @default(now()) @map("created_at") @db.Timestamp(0) updatedAt DateTime? @updatedAt @map("updated_at") @db.Timestamp(0) @@map("cg_tbl_phone_verifications") } model RefreshToken { id BigInt @id @default(autoincrement()) expiresAt DateTime @default(now()) @map("expires_at") @db.Timestamp(0) createdAt DateTime? @default(now()) @map("created_at") @db.Timestamp(0) updatedAt DateTime? @updatedAt @map("updated_at") @db.Timestamp(0) deviceInfo String? @map("device_info") @db.VarChar(255) platform String @db.VarChar(50) refreshToken String @map("refresh_token") @db.VarChar(500) tokenableId BigInt @map("tokenable_id") tokenableType String @map("tokenable_type") @db.VarChar(255) @@map("cg_tbl_refresh_tokens") } model Freelancer { id BigInt @id @default(autoincrement()) freelancerId String @unique @map("freelancer_id") @db.VarChar(100) firstName String? @map("first_name") @db.VarChar(100) lastName String? @map("last_name") @db.VarChar(100) mobile String? @db.VarChar(20) email String? @db.VarChar(150) tradeName String? @map("trade_name") @db.VarChar(150) entityType String? @map("entity_type") @db.VarChar(100) languageIds String? @map("language_ids") @db.LongText bloodGroup String? @map("blood_group") @db.VarChar(20) aadhaarNumber String? @map("aadhaar_number") @db.VarChar(20) panNumber String? @map("pan_number") @db.VarChar(20) gstinNumber String? @map("gstin_number") @db.VarChar(30) cinNumber String? @map("cin_number") @db.VarChar(50) dob DateTime? @map("dob") @db.Date address String? @db.Text state String? @db.VarChar(100) latitude Decimal? @db.Decimal(10, 8) longitude Decimal? @db.Decimal(11, 8) city String? @db.VarChar(100) zone String? @db.LongText pincode String? @db.VarChar(10) bankName String? @map("bank_name") @db.VarChar(150) bankAccountNumber String? @map("bank_account_number") @db.VarChar(50) bankIfscCode String? @map("bank_ifsc_code") @db.VarChar(20) skills String? @db.LongText vehicleFuelTypes String? @map("vehicle_fuel_types") @db.LongText vehicleClasses String? @map("vehicle_classes") @db.LongText evSafetyCertificateFile String? @map("ev_safety_certificate_file") @db.VarChar(255) panCardFile String? @map("pan_card_file") @db.VarChar(255) gstFile String? @map("gst_file") @db.VarChar(255) cinFile String? @map("cin_file") @db.VarChar(255) bankDocumentFile String? @map("bank_document_file") @db.VarChar(255) aadhaarCardFile String? @map("aadhaar_card_file") @db.VarChar(255) profilePhotoFile String? @map("profile_photo_file") @db.VarChar(255) experienceCertificateFile String? @map("experience_certificate_file") @db.VarChar(255) educationCertificateFile String? @map("education_certificate_file") @db.VarChar(255) policeVerificationFile String? @map("police_verification_file") @db.VarChar(255) selfieWithToolsFile String? @map("selfie_with_tools_file") @db.VarChar(255) evCertificationFile String? @map("ev_certification_file") @db.VarChar(255) status Int? @default(0) isVerified Int? @default(0) @map("is_verified") fcmToken String? @map("fcm_token") @db.Text subscriptionId BigInt? @map("subscription_id") subscriptionStartDate DateTime? @map("subscription_start_date") @db.Timestamp(0) subscriptionEndDate DateTime? @map("subscription_end_date") @db.Timestamp(0) createdAt DateTime? @default(now()) @map("created_at") @db.Timestamp(0) updatedAt DateTime? @updatedAt @map("updated_at") @db.Timestamp(0) averageRating Decimal? @default(0.00) @map("avg_rating") @db.Decimal(3, 2) ratingsCount Int @default(0) @map("ratings_count") emergencyContacts FreelancerEmergencyContact[] teamMembers FreelancerTeamMember[] subscriptionPlan SubscriptionPlan? @relation("FreelancerSubscription", fields: [subscriptionId], references: [id], onDelete: NoAction, onUpdate: NoAction) @@index([subscriptionId], map: "cg_tbl_freelancers_subscription_id_fkey") @@map("cg_tbl_freelancers") } model FreelancerTeamMember { id BigInt @id @default(autoincrement()) freelancerId BigInt? @map("freelancer_id") memberName String? @map("member_name") @db.VarChar(100) memberMobile String? @map("member_mobile") @db.VarChar(20) memberAadhaarNumber String? @map("member_aadhaar_number") @db.VarChar(20) memberPhotoFile String? @map("member_photo_file") @db.VarChar(255) status Int? @default(1) createdAt DateTime? @default(now()) @map("created_at") @db.Timestamp(0) updatedAt DateTime? @updatedAt @map("updated_at") @db.Timestamp(0) freelancer Freelancer? @relation(fields: [freelancerId], references: [id], onDelete: Cascade) @@index([freelancerId], map: "cg_tbl_freelancer_team_members_freelancer_id_fkey") @@map("cg_tbl_freelancer_team_members") } model FreelancerEmergencyContact { id BigInt @id @default(autoincrement()) freelancerId BigInt? @map("freelancer_id") contactName String? @map("contact_name") @db.VarChar(100) contactNumber String? @map("contact_number") @db.VarChar(20) relationship String? @db.VarChar(50) status Int? @default(1) createdAt DateTime? @default(now()) @map("created_at") @db.Timestamp(0) updatedAt DateTime? @updatedAt @map("updated_at") @db.Timestamp(0) freelancer Freelancer? @relation(fields: [freelancerId], references: [id], onDelete: Cascade) @@index([freelancerId], map: "cg_tbl_freelancer_emergency_contacts_freelancer_id_fkey") @@map("cg_tbl_freelancer_emergency_contacts") } model Garage { id BigInt @id @default(autoincrement()) garageId String @unique @map("garage_id") @db.VarChar(100) multipleGarages Int? @map("multiple_garages") firstName String? @map("first_name") @db.VarChar(100) lastName String? @map("last_name") @db.VarChar(100) mobile String? @db.VarChar(20) email String? @db.VarChar(150) tradeName String? @map("trade_name") @db.VarChar(150) entityType String? @map("entity_type") @db.VarChar(100) language String? @db.VarChar(50) aadhaarNumber String? @map("aadhaar_number") @db.VarChar(20) panNumber String? @map("pan_number") @db.VarChar(20) gstinNumber String? @map("gstin_number") @db.VarChar(30) cinNumber String? @map("cin_number") @db.VarChar(50) dob DateTime? @map("dob") @db.Date address String? @db.Text state String? @db.VarChar(100) city String? @db.VarChar(100) zone String? @db.LongText pincode String? @db.VarChar(10) latitude Decimal? @db.Decimal(10, 8) longitude Decimal? @db.Decimal(11, 8) bankName String? @map("bank_name") @db.VarChar(150) bankAccountNumber String? @map("bank_account_number") @db.VarChar(50) bankIfscCode String? @map("bank_ifsc_code") @db.VarChar(20) operatingHours String? @map("operating_hours") @db.LongText vehicleFuelTypes String? @map("vehicle_fuel_types") @db.LongText vehicleClasses String? @map("vehicle_classes") @db.LongText evSafetyCertificateFile String? @map("ev_safety_certificate_file") @db.VarChar(255) panCardFile String? @map("pan_card_file") @db.VarChar(255) gstFile String? @map("gst_file") @db.VarChar(255) cinFile String? @map("cin_file") @db.VarChar(255) bankDocumentFile String? @map("bank_document_file") @db.VarChar(255) aadhaarCardFile String? @map("aadhaar_card_file") @db.VarChar(255) profilePhotoFile String? @map("profile_photo_file") @db.VarChar(255) infrastructureImageFile String? @map("infrastructure_image_file") @db.VarChar(255) services Json? @map("services") status Int? @default(0) isParent Int? @default(0) @map("is_parent") @db.TinyInt parentId BigInt? @map("parent_id") isVerified Int? @default(0) @map("is_verified") fcmToken String? @map("fcm_token") @db.Text subscriptionId BigInt? @map("subscription_id") subscriptionStartDate DateTime? @map("subscription_start_date") @db.Timestamp(0) subscriptionEndDate DateTime? @map("subscription_end_date") @db.Timestamp(0) createdAt DateTime? @default(now()) @map("created_at") @db.Timestamp(0) updatedAt DateTime? @updatedAt @map("updated_at") @db.Timestamp(0) averageRating Decimal? @default(0.00) @map("avg_rating") @db.Decimal(3, 2) ratingsCount Int @default(0) @map("ratings_count") subscriptionPlan SubscriptionPlan? @relation("GarageSubscription", fields: [subscriptionId], references: [id], onDelete: NoAction, onUpdate: NoAction) @@index([subscriptionId], map: "cg_tbl_garages_subscription_id_fkey") @@map("cg_tbl_garages") } model CgTblTowingPartners { id BigInt @id @default(autoincrement()) first_name String? @db.VarChar(100) last_name String? @db.VarChar(100) mobile String? @db.VarChar(20) email String? @db.VarChar(150) trade_name String? @db.VarChar(150) language_ids String? @db.LongText entity_type String? @db.VarChar(100) language String? @db.VarChar(50) aadhaar_number String? @db.VarChar(20) pan_number String? @db.VarChar(20) gstin_number String? @db.VarChar(30) cin_number String? @db.VarChar(50) dob DateTime? @db.Date address String? @db.Text state String? @db.VarChar(100) city String? @db.VarChar(100) zone String? @db.LongText pincode String? @db.VarChar(10) bank_name String? @db.VarChar(150) bank_account_number String? @db.VarChar(50) bank_ifsc_code String? @db.VarChar(20) pan_card_file String? @db.VarChar(255) gst_file String? @db.VarChar(255) cin_file String? @db.VarChar(255) bank_document_file String? @db.VarChar(255) aadhaar_card_file String? @db.VarChar(255) profile_photo_file String? @db.VarChar(255) status Int? @default(0) is_verified Int? created_at DateTime? @db.Timestamp(0) updated_at DateTime? @updatedAt @db.Timestamp(0) averageRating Decimal? @default(0.00) @map("avg_rating") @db.Decimal(3, 2) ratingsCount Int @default(0) @map("ratings_count") fcmToken String? @map("fcm_token") @db.Text latitude Decimal? @db.Decimal(10, 8) longitude Decimal? @db.Decimal(11, 8) towingId String @unique @map("towing_id") @db.VarChar(100) @@map("cg_tbl_towing_partners") } model Seller { id BigInt @id @default(autoincrement()) sellerId String? @unique @map("seller_id") @db.VarChar(100) firstName String? @map("first_name") @db.VarChar(100) lastName String? @map("last_name") @db.VarChar(100) mobile String? @db.VarChar(20) email String? @db.VarChar(150) tradeName String? @map("trade_name") @db.VarChar(150) entityType String? @map("entity_type") @db.VarChar(100) aadhaarNumber String? @map("aadhaar_number") @db.VarChar(20) panNumber String? @map("pan_number") @db.VarChar(20) gstinNumber String? @map("gstin_number") @db.VarChar(30) cinNumber String? @map("cin_number") @db.VarChar(50) operatingHours String? @map("operating_hours") @db.LongText specificCommission Int? @map("specific_commission") customerOrderCommission Decimal? @map("customer_order_commission") @db.Decimal(10, 2) garageOrderCommission Decimal? @map("garage_order_commission") @db.Decimal(10, 2) requestedCustomerOrderCommission Decimal? @map("requested_customer_order_commission") @db.Decimal(10, 2) requestedGarageOrderCommission Decimal? @map("requested_garage_order_commission") @db.Decimal(10, 2) bankName String? @map("bank_name") @db.VarChar(150) bankAccountNumber String? @map("bank_account_number") @db.VarChar(50) bankIfscCode String? @map("bank_ifsc_code") @db.VarChar(20) address String? @db.Text latitude Decimal? @db.Decimal(10, 8) longitude Decimal? @db.Decimal(11, 8) state String? @db.VarChar(100) city String? @db.VarChar(100) zone String? @db.LongText pincode String? @db.VarChar(10) panCardFile String? @map("pan_card_file") @db.VarChar(255) gstFile String? @map("gst_file") @db.VarChar(255) cinFile String? @map("cin_file") @db.VarChar(255) cancelledChequeFile String? @map("cancelled_cheque_file") @db.VarChar(255) aadhaarPanSignatoryFile String? @map("aadhaar_pan_signatory_file") @db.VarChar(255) otherDocumentsFile String? @map("other_documents_file") @db.VarChar(255) status Int? @default(0) isVerified Int? @map("is_verified") fcmToken String? @map("fcm_token") @db.Text subscriptionId BigInt? @map("subscription_id") subscriptionStartDate DateTime? @map("subscription_start_date") @db.Timestamp(0) subscriptionEndDate DateTime? @map("subscription_end_date") @db.Timestamp(0) createdAt DateTime? @default(now()) @map("created_at") @db.Timestamp(0) updatedAt DateTime? @updatedAt @map("updated_at") @db.Timestamp(0) coupons Coupon[] sellerProductRequests SellerProductRequest[] sellerProducts SellerProduct[] carts Cart[] averageRating Decimal? @default(0) @map("average_rating") @db.Decimal(3, 2) ratingCount Int? @default(0) @map("rating_count") sellerRatings SellerRating[] productRatings ProductRating[] subscriptionPlan SubscriptionPlan? @relation("SellerSubscription", fields: [subscriptionId], references: [id], onDelete: NoAction, onUpdate: NoAction) @@index([subscriptionId], map: "cg_tbl_sellers_subscription_id_fkey") @@map("cg_tbl_sellers") } model UserAddress { id BigInt @id @default(autoincrement()) userId BigInt? @map("user_id") roleId BigInt? @map("role_id") addressTitle String? @map("address_title") @db.VarChar(100) contactName String? @map("contact_name") @db.VarChar(150) phoneNumber String? @map("phone_number") @db.VarChar(20) flatHouseNo String? @map("flat_house_no") @db.VarChar(255) areaLocality String? @map("area_locality") @db.VarChar(255) landmark String? @map("landmark") @db.VarChar(255) pincode String? @db.VarChar(10) city String? @db.VarChar(100) state String? @db.VarChar(100) latitude Decimal? @db.Decimal(10, 8) longitude Decimal? @db.Decimal(11, 8) fullAddress String? @map("full_address") @db.Text isDefault Int? @default(0) @map("is_default") @db.SmallInt status Int? @default(1) @map("status") @db.SmallInt createdAt DateTime? @default(now()) @map("created_at") @db.Timestamp(0) updatedAt DateTime? @updatedAt @map("updated_at") @db.Timestamp(0) role UserRole? @relation(fields: [roleId], references: [id], onDelete: NoAction, onUpdate: NoAction) @@index([roleId], map: "cg_tbl_user_addresses_role_id_fkey") @@map("cg_tbl_user_addresses") } model BusinessSetting { id BigInt @id @default(autoincrement()) key String @unique value String? @db.LongText createdAt DateTime? @default(now()) @map("created_at") @db.Timestamp(0) updatedAt DateTime? @updatedAt @map("updated_at") @db.Timestamp(0) @@map("cg_tbl_business_settings") } model Coupon { id BigInt @id @default(autoincrement()) couponCode String @unique @map("coupon_code") @db.VarChar(100) title String? @db.VarChar(255) createdType String? @map("created_type") @db.VarChar(100) createdBy BigInt? @map("created_by") vendorId BigInt? @map("vendor_id") zoneIds String? @map("zone_ids") @db.VarChar(255) moduleType ModuleType? @map("module_type") couponType String @map("coupon_type") @db.VarChar(50) applicableUserType String @default("both") @map("applicable_user_type") @db.VarChar(50) userEligibility String? @default("all_users") @map("user_eligibility") @db.VarChar(50) discountValue Decimal @map("discount_value") @db.Decimal(10, 2) maxDiscount Decimal? @map("max_discount") @db.Decimal(10, 2) minOrderValue Decimal @map("min_order_value") @db.Decimal(10, 2) validFrom DateTime? @map("valid_from") @db.Timestamp(0) validTo DateTime? @map("valid_to") @db.Timestamp(0) totalUsageLimit Int? @default(0) @map("total_usage_limit") totalUses Int @default(0) @map("total_uses") adminContributionPercentage Int? @default(0) @map("admin_contribution_percentage") vendorContributionPercentage Int? @default(0) @map("vendor_contribution_percentage") usagePerUser Int? @default(1) @map("usage_per_user") categoryRestrictions String? @map("category_restrictions") @db.LongText allowStacking Int? @default(0) @map("allow_stacking") maxCombinedDiscount Decimal? @map("max_combined_discount") @db.Decimal(10, 2) status Int? @default(1) createdAt DateTime? @default(now()) @map("created_at") @db.Timestamp(0) updatedAt DateTime? @updatedAt @map("updated_at") @db.Timestamp(0) vendor Seller? @relation(fields: [vendorId], references: [id], onDelete: NoAction, onUpdate: NoAction) @@index([vendorId], map: "cg_tbl_coupons_vendor_id_fkey") @@map("cg_tbl_coupons") } model AdminRole { id BigInt @id @default(autoincrement()) roleName String @map("role_name") @db.VarChar(100) roleSlug String @unique @map("role_slug") @db.VarChar(100) status Int? @default(1) createdAt DateTime? @default(now()) @map("created_at") @db.Timestamp(0) updatedAt DateTime? @updatedAt @map("updated_at") @db.Timestamp(0) adminUsers AdminUser[] @@map("cg_tbl_admin_roles") } model AdminUser { id BigInt @id @default(autoincrement()) roleId BigInt @map("role_id") fullName String @map("full_name") @db.VarChar(255) email String @unique @db.VarChar(150) mobile String? @db.VarChar(20) password String @db.VarChar(255) profilePhotoFile String? @map("profile_photo_file") @db.VarChar(255) lastLoginAt DateTime? @map("last_login_at") @db.Timestamp(0) status Int? @default(1) createdAt DateTime? @default(now()) @map("created_at") @db.Timestamp(0) updatedAt DateTime? @updatedAt @map("updated_at") @db.Timestamp(0) age Int? address String? @db.Text gender Gender? role AdminRole @relation(fields: [roleId], references: [id], onDelete: NoAction, onUpdate: NoAction) towingServices TowingService[] zones Zone[] subscriptionPlans SubscriptionPlan[] advertisementConfigs AdvertisementConfig[] @@index([roleId], map: "cg_tbl_admin_users_role_id_fkey") @@map("cg_tbl_admin_users") } model Tutorial { id BigInt @id @default(autoincrement()) roleId BigInt? @map("role_id") youtubeUrl String @map("youtube_url") @db.VarChar(255) status Int? @default(1) createdAt DateTime? @default(now()) @map("created_at") @db.Timestamp(0) createdBy BigInt? @map("created_by") updatedAt DateTime? @updatedAt @map("updated_at") @db.Timestamp(0) role UserRole? @relation(fields: [roleId], references: [id], onDelete: NoAction, onUpdate: NoAction) @@index([roleId], map: "cg_table_tutorials_role_id_fkey") @@map("cg_table_tutorials") } model TaxSetup { id BigInt @id @default(autoincrement()) taxSetup Decimal @db.Decimal(5, 2) status Int @default(1) @db.TinyInt createdAt DateTime @default(now()) updatedAt DateTime @updatedAt createdBy BigInt? @map("created_by") helperPricings HelperPricing[] subscriptionPlans SubscriptionPlan[] @@map("cg_tbl_tax_setups") } model Category { id BigInt @id @default(autoincrement()) @db.UnsignedBigInt categoryName String @map("category_name") @db.VarChar(255) slug String @unique @db.VarChar(255) categoryImage String? @map("category_image") @db.VarChar(500) status Int @default(1) @db.TinyInt createdAt DateTime? @default(now()) @map("created_at") @db.Timestamp(0) createdBy BigInt? @map("created_by") updatedAt DateTime? @updatedAt @map("updated_at") @db.Timestamp(0) isAccident Int @default(0) @map("is_accident") @db.TinyInt categorySubCategorySetups CategorySubCategorySetup[] gigModificationReasons GigModificationReason[] sellerProducts SellerProduct[] serviceReasons ServiceReason[] serviceCarts ServiceCart[] @@map("cg_tbl_categories") } model SubCategory { id BigInt @id @default(autoincrement()) @db.UnsignedBigInt subCategoryName String @map("sub_category_name") @db.VarChar(255) slug String @unique @db.VarChar(255) minimumTime Int? @map("minimum_time") maximumTime Int? @map("maximum_time") coverImage String? @map("cover_image") @db.VarChar(500) galleryImages String? @map("gallery_images") @db.LongText aboutServices String? @map("about_services") @db.LongText prerequisites String? @map("prerequisites") @db.LongText contentBlocks String? @map("content_blocks") @db.LongText isSpecialized Boolean @default(false) @map("is_specialized") status Int @default(1) @db.TinyInt createdAt DateTime @default(now()) @map("created_at") createdBy BigInt? @map("created_by") updatedAt DateTime @updatedAt @map("updated_at") categorySubCategorySetups CategorySubCategorySetup[] sellerProducts SellerProduct[] serviceCarts ServiceCart[] @@map("cg_tbl_sub_categories") } model CategorySubCategorySetup { id BigInt @id @default(autoincrement()) @db.UnsignedBigInt categoryId BigInt @map("category_id") @db.UnsignedBigInt subCategoryId BigInt? @map("sub_category_id") @db.UnsignedBigInt roleId BigInt @map("role_id") estAmountEnabled Int @default(0) @map("est_amount_enabled") @db.TinyInt estPrepaidAmount Decimal @default(0.00) @map("est_prepaid_amount") @db.Decimal(10, 2) pickupDropEnabled Int @default(0) @map("pickup_drop_enabled") @db.TinyInt pickupDropAmount Decimal? @map("pickup_drop_amount") @db.Decimal(10, 2) pricing Decimal @db.Decimal(10, 2) priority Int @default(0) serviceType ServiceType @default(garage) @map("service_type") discountType DiscountType? @map("discount_type") discountValue Decimal? @map("discount_value") @db.Decimal(10, 2) customPayoutConfigurationEnabled Int @default(0) @map("custom_payout_configuration_enabled") @db.TinyInt providerPayoutPercentage Decimal? @map("provider_payout_percentage") @db.Decimal(5, 2) platformHoldPercentage Decimal? @map("platform_hold_percentage") @db.Decimal(5, 2) holdPeriodHours Int? @map("hold_period_hours") status Int @default(1) @db.TinyInt createdAt DateTime @default(now()) @map("created_at") createdBy BigInt? @map("created_by") updatedAt DateTime @updatedAt @map("updated_at") vehicleClassId BigInt @map("vehicle_class_id") vehicleFuelTypeId BigInt @map("vehicle_fuel_type_id") category Category @relation(fields: [categoryId], references: [id], onDelete: Cascade) role UserRole @relation(fields: [roleId], references: [id], onDelete: Cascade) subCategory SubCategory? @relation(fields: [subCategoryId], references: [id], onDelete: Cascade) vehicleClass VehicleClass @relation(fields: [vehicleClassId], references: [id], onDelete: Cascade) vehicleFuelType VehicleFuelType @relation(fields: [vehicleFuelTypeId], references: [id], onDelete: Cascade) @@unique([categoryId, subCategoryId, roleId, serviceType, vehicleClassId, vehicleFuelTypeId], name: "category_sub_role_service_vehicle_unique") @@index([categoryId], map: "cg_tbl_category_sub_category_setup_category_id_fkey") @@index([subCategoryId], map: "cg_tbl_category_sub_category_setup_sub_category_id_fkey") @@index([roleId], map: "cg_tbl_category_sub_category_setup_role_id_fkey") @@index([vehicleClassId], map: "cg_tbl_category_sub_category_setup_vehicle_class_id_fkey") @@index([vehicleFuelTypeId], map: "cg_tbl_category_sub_category_setup_vehicle_fuel_type_id_fkey") @@map("cg_tbl_category_sub_category_setup") } enum RatingModuleType { ORDER_PLACEMENT SELLER PRODUCT SERVICE } model RatingReason { id BigInt @id @default(autoincrement()) @db.UnsignedBigInt reason String @db.VarChar(255) appNameId BigInt @map("app_name") moduleType RatingModuleType @default(ORDER_PLACEMENT) @map("module_type") status Int @default(1) @db.TinyInt createdAt DateTime @default(now()) @map("created_at") createdBy BigInt? @map("created_by") updatedAt DateTime @updatedAt @map("updated_at") appName UserRole @relation(fields: [appNameId], references: [id], onDelete: Cascade) @@index([appNameId], map: "cg_tbl_rattings_reason_app_name_fkey") @@index([moduleType]) @@map("cg_tbl_rattings_reason") } model SkillSet { id BigInt @id @default(autoincrement()) skillName String @map("skill_name") @db.VarChar(255) status Int? userRoleId BigInt? @map("user_role") createdAt DateTime? @default(now()) @map("created_at") @db.Timestamp(0) updatedAt DateTime? @updatedAt @map("updated_at") @db.Timestamp(0) userRole UserRole? @relation(fields: [userRoleId], references: [id]) @@index([userRoleId], map: "cg_tbl_skill_set_user_role_fkey") @@map("cg_tbl_skill_set") } model ServiceReason { id BigInt @id @default(autoincrement()) @db.UnsignedBigInt categoryId BigInt @map("category_id") @db.UnsignedBigInt reasons String? @map("reasons") @db.LongText status Int @default(1) @db.TinyInt createdAt DateTime? @default(now()) @map("created_at") @db.Timestamp(0) createdBy BigInt? @map("created_by") updatedAt DateTime? @updatedAt @map("updated_at") @db.Timestamp(0) category Category @relation(fields: [categoryId], references: [id], onDelete: Cascade) @@index([categoryId], map: "cg_tbl_service_reason_category_id_fkey") @@map("cg_tbl_service_reason") } model Banner { id BigInt @id @default(autoincrement()) title String @db.VarChar(255) description String? @db.Text bannerImage String @map("banner_image") @db.VarChar(255) zoneId BigInt @map("zone_id") status Int? @default(1) @db.TinyInt createdBy BigInt? @map("created_by") createdAt DateTime? @default(now()) @map("created_at") @db.Timestamp(0) updatedAt DateTime? @updatedAt @map("updated_at") @db.Timestamp(0) zone Zone @relation(fields: [zoneId], references: [id], onDelete: Cascade) @@index([zoneId], map: "cg_tbl_banners_zone_id_fkey") @@map("cg_tbl_banners") } model Advertisement { id BigInt @id @default(autoincrement()) userId BigInt @map("user_id") userRoleId BigInt? @map("user_role_id") advertisementType AdvertisementType @map("advertisement_type") title String? @db.VarChar(255) productId BigInt? @map("product_id") bannerImage String @map("banner_image") @db.VarChar(255) zoneId BigInt @map("zone_id") fromDate DateTime @map("from_date") @db.DateTime(0) toDate DateTime @map("to_date") @db.DateTime(0) amount Decimal? @db.Decimal(10, 2) paymentStatus PaymentStatus? @map("payment_status") approvalStatus ApprovalStatus? @default(pending) @map("approval_status") rejectedRemarks String? @map("rejected_remarks") @db.Text actionBy BigInt? @map("action_by") actionAt DateTime? @map("action_at") @db.DateTime(0) status Int? @default(1) @db.TinyInt createdAt DateTime? @default(now()) @map("created_at") @db.Timestamp(0) updatedAt DateTime? @updatedAt @map("updated_at") @db.Timestamp(0) userRole UserRole? @relation(fields: [userRoleId], references: [id], onDelete: Cascade, onUpdate: NoAction) zone Zone @relation(fields: [zoneId], references: [id], onDelete: Cascade) @@index([zoneId], map: "cg_tbl_advertisements_zone_id_fkey") @@index([userRoleId], map: "cg_tbl_advertisements_user_role_id_fkey") @@map("cg_tbl_advertisements") } model Zone { id BigInt @id @default(autoincrement()) zoneName String @map("zone_name") @db.VarChar(255) zoneCode String @map("zone_code") @db.VarChar(255) status Int? @default(1) @db.TinyInt coordinates Unsupported("polygon") createdAt DateTime? @default(now()) @map("created_at") @db.Timestamp(0) updatedAt DateTime? @updatedAt @map("updated_at") @db.Timestamp(0) createdBy BigInt? @map("created_by") createdByUser AdminUser? @relation(fields: [createdBy], references: [id], onDelete: NoAction, onUpdate: NoAction) advertisements Advertisement[] banners Banner[] @@index([createdBy], map: "cg_tbl_zones_created_by_fkey") @@map("cg_tbl_zones") } model GigModificationReason { id BigInt @id @default(autoincrement()) @db.UnsignedBigInt categoryId BigInt @map("category_id") @db.UnsignedBigInt reasons String? @map("reasons") @db.LongText status Int @default(1) @db.TinyInt createdAt DateTime? @default(now()) @map("created_at") @db.Timestamp(0) createdBy BigInt? @map("created_by") updatedAt DateTime? @updatedAt @map("updated_at") @db.Timestamp(0) category Category @relation(fields: [categoryId], references: [id], onDelete: Cascade) @@index([categoryId], map: "cg_tbl_gig_modification_reason_category_id_fkey") @@map("cg_tbl_gig_modification_reason") } model VehicleClass { id BigInt @id @default(autoincrement()) name String @db.VarChar(100) slug String @unique @db.VarChar(100) status Int? @default(1) @db.TinyInt createdAt DateTime? @default(now()) @map("created_at") @db.Timestamp(0) updatedAt DateTime? @updatedAt @map("updated_at") @db.Timestamp(0) categorySubCategorySetups CategorySubCategorySetup[] vehicles VehicleMaster[] @@map("cg_tbl_vehicle_classes") } model VehicleFuelType { id BigInt @id @default(autoincrement()) name String @db.VarChar(100) slug String @unique @db.VarChar(100) status Int? @default(1) @db.TinyInt createdAt DateTime? @default(now()) @map("created_at") @db.Timestamp(0) updatedAt DateTime? @updatedAt @map("updated_at") @db.Timestamp(0) categorySubCategorySetups CategorySubCategorySetup[] vehicles VehicleMaster[] @@map("cg_tbl_vehicle_fuel_types") } model Language { id BigInt @id @default(autoincrement()) name String @db.VarChar(100) slug String @unique @db.VarChar(100) status Int? @default(1) @db.TinyInt createdAt DateTime? @default(now()) @map("created_at") @db.Timestamp(0) updatedAt DateTime? @updatedAt @map("updated_at") @db.Timestamp(0) @@map("cg_tbl_languages") } model ProfileUpdateRequest { id BigInt @id @default(autoincrement()) userId BigInt @map("user_id") userRoleId BigInt? @map("user_role_id") changeData String @map("change_data") @db.LongText status Int? @default(0) @db.TinyInt actionBy BigInt? @map("action_by") actionAt DateTime? @map("action_at") @db.Timestamp(0) rejectionReason String? @map("rejection_reason") @db.Text createdAt DateTime? @default(now()) @map("created_at") @db.Timestamp(0) updatedAt DateTime? @updatedAt @map("updated_at") @db.Timestamp(0) userRole UserRole? @relation(fields: [userRoleId], references: [id], onDelete: NoAction, onUpdate: NoAction) @@index([userRoleId], map: "cg_tbl_profile_update_requests_user_role_id_fkey") @@map("cg_tbl_profile_update_requests") } model TowingQuoteTime { id BigInt @id @default(autoincrement()) @db.UnsignedBigInt timeValue String @map("time_value") @db.VarChar(100) status Int? @default(0) @db.TinyInt lastActive Int? @default(0) @map("last_active") @db.TinyInt createdAt DateTime? @default(now()) @map("created_at") @db.Timestamp(0) createdBy BigInt? @map("created_by") updatedAt DateTime? @updatedAt @map("updated_at") @db.Timestamp(0) @@map("cg_tbl_towing_quote_time") } model TowingService { id BigInt @id @default(autoincrement()) towingServiceName String @db.VarChar(255) image String @map("image") @db.LongText status Int? @default(1) @db.TinyInt createdBy BigInt? @map("created_by") createdAt DateTime? @default(now()) @map("created_at") @db.Timestamp(0) updatedAt DateTime? @updatedAt @map("updated_at") @db.Timestamp(0) createdByUser AdminUser? @relation(fields: [createdBy], references: [id], onDelete: NoAction, onUpdate: NoAction) @@index([createdBy], map: "cg_tbl_towing_service_created_by_fkey") @@map("cg_tbl_towing_service") } model HelperPricing { id Int @id @default(autoincrement()) durationHours Float baseFeeAmount Decimal @db.Decimal(10, 2) gstPercentageId BigInt @map("gst_percentage_id") status Int @default(1) @db.TinyInt createdAt DateTime @default(now()) createdBy BigInt? @map("created_by") updatedAt DateTime @updatedAt gstSetup TaxSetup @relation(fields: [gstPercentageId], references: [id], onDelete: NoAction, onUpdate: NoAction) @@index([gstPercentageId], map: "cg_tbl_helper_pricing_gst_percentage_id_fkey") @@map("cg_tbl_helper_pricing") } model CancellationReason { id BigInt @id @default(autoincrement()) reason String @db.VarChar(255) appId BigInt @map("app_id") status Int? @default(1) @db.TinyInt createdAt DateTime? @default(now()) @map("created_at") @db.Timestamp(0) createdBy BigInt? @map("created_by") updatedAt DateTime? @updatedAt @map("updated_at") @db.Timestamp(0) app UserRole @relation(fields: [appId], references: [id], onDelete: Cascade) @@index([appId], map: "cg_tbl_cancellation_reasons_app_id_fkey") @@map("cg_tbl_cancellation_reasons") } model VintageVehicleRequest { id BigInt @id @default(autoincrement()) @db.UnsignedBigInt requestType VintageRequestType? @default(spare_part) @map("request_type") make String? @db.VarChar(100) year Int? @db.Year model String? @db.VarChar(255) fuelType String? @map("fuel_type") @db.VarChar(50) vehicleClass String? @map("vehicle_class") @db.VarChar(100) chassisNumber String? @map("chassis_number") @db.VarChar(100) partName String? @map("part_name") @db.VarChar(255) productType VintageProductType? @map("product_type") quantity Int? @default(1) remarks String? @db.Text images String? @db.LongText status Int? @default(0) statusHistory String? @map("status_history") @db.LongText modificationCategory String? @map("modification_category") @db.VarChar(100) userId BigInt? @map("user_id") roleId BigInt? @map("role_id") platform VintagePlatform createdAt DateTime? @default(now()) @map("created_at") @db.Timestamp(0) updatedAt DateTime? @updatedAt @map("updated_at") @db.Timestamp(0) @@map("cg_tbl_vintage_vehicle_requests") } model VehicleMaster { id BigInt @id @default(autoincrement()) @db.UnsignedBigInt userId BigInt @map("user_id") @db.UnsignedBigInt userRoleId BigInt @map("user_role_id") vehicleNo String @map("vehicle_no") @db.VarChar(50) make String @db.VarChar(100) model String @db.VarChar(100) year Int @db.Year chassisNo String? @map("chassis_no") @db.VarChar(100) odometerReadingKm Int @default(0) @map("odometer_reading_km") @db.UnsignedInt vehicleClassId BigInt @map("vehicle_class_id") vehicleFuelTypeId BigInt @map("vehicle_fuel_type_id") vehicleImage String? @map("vehicle_image") @db.VarChar(255) vehicleRcImg String? @map("vehicle_rc_img") @db.VarChar(255) status Int @default(1) @db.TinyInt deletedStatus Int @default(0) @map("deleted_status") @db.TinyInt createdAt DateTime? @default(now()) @map("created_at") @db.Timestamp(0) updatedAt DateTime? @updatedAt @map("updated_at") @db.Timestamp(0) userRole UserRole @relation(fields: [userRoleId], references: [id], onDelete: NoAction, onUpdate: NoAction) vehicleClass VehicleClass @relation(fields: [vehicleClassId], references: [id], onDelete: NoAction, onUpdate: NoAction) vehicleFuelType VehicleFuelType @relation(fields: [vehicleFuelTypeId], references: [id], onDelete: NoAction, onUpdate: NoAction) @@index([userRoleId], map: "cg_tbl_vehicles_master_user_role_id_fkey") @@index([vehicleClassId], map: "cg_tbl_vehicles_master_vehicle_class_id_fkey") @@index([vehicleFuelTypeId], map: "cg_tbl_vehicles_master_vehicle_fuel_type_id_fkey") @@map("cg_tbl_vehicles_master") } model Notification { id BigInt @id @default(autoincrement()) userId BigInt @map("user_id") userRoleId BigInt @map("user_role_id") data String? @db.LongText platform String? @db.VarChar(50) isRead Boolean @default(false) @map("is_read") createdAt DateTime? @default(now()) @map("created_at") @db.Timestamp(0) @@map("cg_tbl_user_notifications") } model Ticket { id BigInt @id @default(autoincrement()) ticketId String? @unique @map("ticket_id") @db.VarChar(100) vehicleNo String? @map("vehicle_no") @db.VarChar(50) issueType TicketIssueType @map("issue_type") referenceNo String? @map("reference_no") @db.VarChar(100) images String? @db.LongText remarks String? @db.Text priority TicketPriority status TicketStatus @default(open) statusHistory Json? @map("status_history") userId BigInt? @map("user_id") userRoleId BigInt? @map("user_role_id") platform TicketPlatform createdAt DateTime? @default(now()) @map("created_at") @db.Timestamp(0) updatedAt DateTime? @updatedAt @map("updated_at") @db.Timestamp(0) @@map("cg_tbl_tickets") } model SubscriptionPlan { id BigInt @id @default(autoincrement()) userRoleId BigInt? @map("user_role_id") title String @db.VarChar(255) planType String @map("plan_type") @db.VarChar(50) price Decimal @db.Decimal(10, 2) gstPercentage Decimal? @map("gst_percentage") @db.Decimal(5, 2) gstPercentageId BigInt? @map("gst_percentage_id") features String @db.LongText status Int? @default(1) @db.TinyInt createdAt DateTime? @default(now()) @map("created_at") @db.Timestamp(0) updatedAt DateTime? @updatedAt @map("updated_at") @db.Timestamp(0) createdBy BigInt? @map("created_by") createdByUser AdminUser? @relation(fields: [createdBy], references: [id], onDelete: NoAction, onUpdate: NoAction) freelancers Freelancer[] @relation("FreelancerSubscription") garages Garage[] @relation("GarageSubscription") sellers Seller[] @relation("SellerSubscription") gstSetup TaxSetup? @relation(fields: [gstPercentageId], references: [id], onDelete: NoAction, onUpdate: NoAction) @@index([createdBy], map: "cg_tbl_subscription_plans_created_by_fkey") @@map("cg_tbl_subscription_plans") } model SubscriptionOrder { id BigInt @id @default(autoincrement()) userId BigInt @map("user_id") userRoleId BigInt @map("user_role_id") subscriptionPlanId BigInt @map("subscription_plan_id") planTitle String @map("plan_title") @db.VarChar(100) planType SubscriptionPlanTypeLower @map("plan_type") amount Decimal @db.Decimal(10, 2) gstPercentage Decimal @map("gst_percentage") @db.Decimal(5, 2) gstAmount Decimal @map("gst_amount") @db.Decimal(10, 2) totalAmount Decimal @map("total_amount") @db.Decimal(10, 2) gatewayName String? @map("gateway_name") @db.VarChar(100) gatewayOrderId String? @map("gateway_order_id") @db.VarChar(255) gatewayPaymentId String? @map("gateway_payment_id") @db.VarChar(255) paymentStatus SubscriptionPaymentStatus @map("payment_status") status Int? @default(1) @db.TinyInt createdAt DateTime? @default(now()) @map("created_at") @db.Timestamp(0) updatedAt DateTime? @updatedAt @map("updated_at") @db.Timestamp(0) @@map("cg_tbl_temp_subscription_orders") } model UserSubscription { id BigInt @id @default(autoincrement()) userId BigInt @map("user_id") userRoleId BigInt @map("user_role_id") subscriptionPlanId BigInt @map("subscription_plan_id") planTitle String @map("plan_title") @db.VarChar(100) planType SubscriptionPlanTypeLower @map("plan_type") amount Decimal @db.Decimal(10, 2) gstPercentage Decimal @map("gst_percentage") @db.Decimal(5, 2) gstAmount Decimal @map("gst_amount") @db.Decimal(10, 2) totalAmount Decimal @map("total_amount") @db.Decimal(10, 2) gatewayName String? @map("gateway_name") @db.VarChar(100) gatewayOrderId String? @map("gateway_order_id") @db.VarChar(255) gatewayPaymentId String? @map("gateway_payment_id") @db.VarChar(255) status Int? @default(1) @db.TinyInt subscriptionStartDate DateTime? @map("subscription_start_date") @db.Timestamp(0) subscriptionEndDate DateTime? @map("subscription_end_date") @db.Timestamp(0) createdAt DateTime? @default(now()) @map("created_at") @db.Timestamp(0) updatedAt DateTime? @updatedAt @map("updated_at") @db.Timestamp(0) @@map("cg_tbl_user_subscriptions") } model Transaction { id BigInt @id @default(autoincrement()) userId BigInt @map("user_id") roleId BigInt @map("role_id") platform String? @db.VarChar(50) referenceType String? @map("reference_type") @db.VarChar(100) referenceId BigInt? @map("reference_id") entryType TransactionEntryType @map("entry_type") amount Decimal @db.Decimal(10, 2) gatewayName String? @map("gateway_name") @db.VarChar(100) gatewayOrderId String? @map("gateway_order_id") @db.VarChar(255) gatewayPaymentId String? @map("gateway_payment_id") @db.VarChar(255) status Int? @default(1) @db.TinyInt remarks String? @db.Text createdAt DateTime? @default(now()) @map("created_at") @db.Timestamp(0) updatedAt DateTime? @updatedAt @map("updated_at") @db.Timestamp(0) @@map("cg_tbl_transactions") } model Product { id BigInt @id @default(autoincrement()) @db.UnsignedBigInt techdocArticleId BigInt @unique(map: "uk_techdoc_article_id") @map("techdoc_article_id") @db.UnsignedBigInt techdocBrandId BigInt @map("techdoc_brand_id") @db.UnsignedBigInt articleNumber String @map("article_number") @db.VarChar(100) brandName String @map("brand_name") @db.VarChar(255) status Int @default(1) @db.TinyInt createdAt DateTime @default(now()) @map("created_at") updatedAt DateTime @updatedAt @map("updated_at") tecdocAssemblyGroupNodeId BigInt? @map("tecdoc_assembly_group_node_id") @db.UnsignedBigInt dataSupplierId BigInt? @map("data_supplier_id") @db.UnsignedBigInt genericArticleId BigInt? @map("generic_article_id") @db.UnsignedBigInt genericArticleName String? @map("generic_article_name") @db.VarChar(500) isRecommended Int @default(0) @map("is_recommended") @db.TinyInt averageRating Decimal @default(0) @map("average_rating") @db.Decimal(3, 2) ratingCount Int @default(0) @map("rating_count") sellerProductRequests SellerProductRequest[] sellerProducts SellerProduct[] carts Cart[] wishlists Wishlist[] productRatings ProductRating[] @@index([articleNumber], map: "idx_article_number") @@index([techdocBrandId], map: "idx_brand_id") @@index([tecdocAssemblyGroupNodeId], map: "idx_tecdoc_assembly_group_node_id") @@index([dataSupplierId], map: "idx_data_supplier_id") @@index([genericArticleId], map: "idx_generic_article_id") @@map("cg_tbl_products") } model SellerProductRequest { id BigInt @id @default(autoincrement()) @db.UnsignedBigInt sellerId BigInt @map("seller_id") productId BigInt @map("product_id") @db.UnsignedBigInt data String? @map("data") @db.LongText type String @map("type") @db.VarChar(50) approvalStatus Int @default(0) @map("approval_status") @db.TinyInt approvedBy BigInt? @map("approved_by") approvedAt DateTime? @map("approved_at") rejectionReason String? @map("rejection_reason") @db.Text status Int @default(1) @db.TinyInt createdAt DateTime @default(now()) @map("created_at") updatedAt DateTime @updatedAt @map("updated_at") product Product @relation(fields: [productId], references: [id], onDelete: Cascade) seller Seller @relation(fields: [sellerId], references: [id], onDelete: Cascade) @@index([sellerId], map: "idx_seller_id") @@index([productId], map: "idx_product_id") @@index([approvalStatus], map: "idx_approval_status") @@map("cg_tbl_seller_product_requests") } model SellerProduct { id BigInt @id @default(autoincrement()) @db.UnsignedBigInt sellerId BigInt @map("seller_id") productId BigInt @map("product_id") @db.UnsignedBigInt categoryId BigInt? @map("category_id") @db.UnsignedBigInt subCategoryId BigInt? @map("subcategory_id") @db.UnsignedBigInt mrp Decimal? @db.Decimal(10, 2) customerSellingPrice Decimal @map("customer_selling_price") @db.Decimal(10, 2) garageSellingPrice Decimal @map("garage_selling_price") @db.Decimal(10, 2) customerDiscountType String? @map("customer_discount_type") @db.VarChar(50) customerDiscount Decimal? @map("customer_discount") @db.Decimal(10, 2) isReturnable Int? @default(0) @map("is_returnable") @db.TinyInt returnDays Int? @map("return_days") tax Decimal? @db.Decimal(10, 2) garageDiscountType String? @map("garage_discount_type") @db.VarChar(50) garageDiscount Decimal? @map("garage_discount") @db.Decimal(10, 2) warrantyEnabled Int? @default(0) @map("warranty_enabled") @db.TinyInt warrantyDuration Int? @map("warranty_duration") warrantyDurationType WarrantyDurationType? @map("warranty_duration_type") warrantyDocument String? @map("warranty_document") @db.VarChar(500) status Int @default(1) @db.TinyInt createdAt DateTime @default(now()) @map("created_at") updatedAt DateTime @updatedAt @map("updated_at") isInStock Int @default(1) @map("is_in_stock") @db.TinyInt category Category? @relation(fields: [categoryId], references: [id]) product Product @relation(fields: [productId], references: [id], onDelete: Cascade) seller Seller @relation(fields: [sellerId], references: [id], onDelete: Cascade) subCategory SubCategory? @relation(fields: [subCategoryId], references: [id]) @@unique([sellerId, productId], name: "uk_seller_product") @@index([sellerId], map: "idx_seller_id") @@index([productId], map: "idx_product_id") @@index([categoryId], map: "cg_tbl_seller_products_category_id_fkey") @@index([subCategoryId], map: "cg_tbl_seller_products_subcategory_id_fkey") @@map("cg_tbl_seller_products") } enum ServiceType { garage home both } enum DiscountType { flat percentage } enum Gender { male female others } enum AdvertisementType { banner product store } enum PaymentStatus { pending paid failed refunded } enum ApprovalStatus { pending approved rejected } enum VintageProductType { oem after_market } enum VintagePlatform { app web } enum VintageRequestType { spare_part service } enum ModuleType { gig order } enum TicketIssueType { gig order other } enum TicketPriority { low medium high } enum TicketStatus { open inprogress closed } enum TicketPlatform { app web } enum SubscriptionPlanTypeLower { monthly yearly } enum SubscriptionPaymentStatus { pending success failed cancelled } enum TransactionEntryType { CREDIT DEBIT } enum WarrantyDurationType { day month year } model Cart { id BigInt @id @default(autoincrement()) userId BigInt @map("user_id") userRoleId BigInt @map("user_role_id") sellerId BigInt @map("seller_id") productId BigInt @map("product_id") @db.UnsignedBigInt quantity Int @default(1) price Decimal @db.Decimal(10, 2) createdAt DateTime? @default(now()) @map("created_at") @db.Timestamp(0) updatedAt DateTime? @updatedAt @map("updated_at") @db.Timestamp(0) product Product @relation(fields: [productId], references: [id], onDelete: Cascade) seller Seller @relation(fields: [sellerId], references: [id], onDelete: Cascade) @@index([userId, userRoleId], map: "idx_cart_user") @@index([productId], map: "idx_cart_product") @@index([sellerId], map: "idx_cart_seller") @@map("cg_tbl_cart") } model ServiceCart { id BigInt @id @default(autoincrement()) userId BigInt @map("user_id") userRoleId BigInt @map("user_role_id") categoryId BigInt @map("category_id") @db.UnsignedBigInt subCategoryId BigInt? @map("sub_category_id") @db.UnsignedBigInt serviceType ServiceType @default(garage) @map("service_type") providerRoleId BigInt? @map("provider_role_id") createdAt DateTime? @default(now()) @map("created_at") @db.Timestamp(0) updatedAt DateTime? @updatedAt @map("updated_at") @db.Timestamp(0) category Category @relation(fields: [categoryId], references: [id], onDelete: Cascade) subCategory SubCategory? @relation(fields: [subCategoryId], references: [id], onDelete: Cascade) providerRole UserRole? @relation("ServiceCartProviderRole", fields: [providerRoleId], references: [id]) @@index([userId, userRoleId], map: "idx_service_cart_user") @@index([categoryId], map: "idx_service_cart_category") @@index([subCategoryId], map: "idx_service_cart_sub_category") @@index([providerRoleId], map: "idx_service_cart_provider_role") @@map("cg_tbl_service_cart") } model Wishlist { id BigInt @id @default(autoincrement()) userId BigInt @map("user_id") userRoleId BigInt @map("user_role_id") productId BigInt @map("product_id") @db.UnsignedBigInt createdAt DateTime? @default(now()) @map("created_at") @db.Timestamp(0) updatedAt DateTime? @updatedAt @map("updated_at") @db.Timestamp(0) product Product @relation(fields: [productId], references: [id], onDelete: Cascade) @@unique([userId, userRoleId, productId], name: "uk_wishlist_user_product") @@index([userId, userRoleId], map: "idx_wishlist_user") @@index([productId], map: "idx_wishlist_product") @@map("cg_tbl_wishlist") } enum GigCancelledBy { user provider } enum GigType { HALFDAY FULLDAY MONTHLY } model Gig { id BigInt @id @default(autoincrement()) gigNumber String @unique @map("gig_number") @db.VarChar(50) userId BigInt @map("user_id") userRoleId BigInt? @map("user_role_id") providerType GigProviderType? @map("provider_type") providerId BigInt? @map("provider_id") vehicleDetails Json? @map("vehicle_details") vehicleCondition String? @map("vehicle_condition") @db.VarChar(255) reasonId BigInt? @map("reason_id") isPickupDropEnabled Boolean @default(false) isAccident Int @default(0) @map("is_accident") @db.TinyInt addressDetails Json? @map("address_details") dropAddressDetails Json? @map("drop_address_details") baseAmount Decimal? @map("base_amount") @db.Decimal(10, 2) gstPercentage Decimal? @map("gst_percentage") @db.Decimal(5, 2) gstAmount Decimal? @map("gst_amount") @db.Decimal(10, 2) grossAmount Decimal? @map("gross_amount") @db.Decimal(10, 2) commissionPercentage Decimal? @default(0) @map("commission_percentage") @db.Decimal(5, 2) commissionAmount Decimal? @default(0) @map("commission_amount") @db.Decimal(10, 2) commissionGstPercentage Decimal? @map("commission_gst_percentage") @db.Decimal(5, 2) commissionGstAmount Decimal? @map("commission_gst_amount") @db.Decimal(10, 2) tcsAmount Decimal? @map("tcs_amount") @db.Decimal(10, 2) tdsAmount Decimal? @map("tds_amount") @db.Decimal(10, 2) otherChargesLabel String? @map("other_charges_label") @db.VarChar(255) otherChargesType String? @map("other_charges_type") @db.VarChar(50) otherChargesValue Decimal? @map("other_charges_value") @db.Decimal(10, 2) otherChargesAmount Decimal? @map("other_charges_amount") @db.Decimal(10, 2) payableAmount Decimal? @default(0) @map("payable_amount") @db.Decimal(10, 2) status String @db.VarChar(100) quoteWindowExpiresAt DateTime? @map("quote_window_expires_at") driverDetails Json? @map("driver_details") allottedOtp String? @map("allotted_otp") @db.VarChar(10) pickupOtp String? @map("pickup_otp") @db.VarChar(10) cancellationOtp String? @map("cancellation_otp") @db.VarChar(10) arrivedAt DateTime? @map("arrived_at") @db.DateTime(0) startedAt DateTime? @map("started_at") @db.DateTime(0) completedAt DateTime? @map("completed_at") @db.DateTime(0) remarks String? @db.Text description String? @db.Text urgency String? @db.VarChar(50) isScheduled Boolean @default(false) @map("is_scheduled") scheduledAt DateTime? @map("scheduled_at") gigType GigType? @map("gig_type") scheduledEndAt DateTime? @map("scheduled_end_at") @db.Timestamp(0) zoneId Int? @map("zone_id") // Stores the reason provided when the gig is cancelled. cancelReason String? @map("cancel_reason") @db.Text // Indicates who cancelled the gig (USER, PROVIDER, ADMIN, or SYSTEM). cancelledBy GigCancelledBy? @map("cancelled_by") // Records the date and time when the gig was cancelled. cancelledAt DateTime? @map("cancelled_at") @db.DateTime(0) inspectionCharge Decimal? @default(0) @map("inspection_charge") @db.Decimal(10, 2) transactionId String? @map("transaction_id") @db.VarChar(255) initialAttachments Json? @map("initial_attachments") arrivalAttachments Json? @map("arrival_attachments") completionAttachments Json? @map("completion_attachments") validationStatus String? @map("validation_status") @db.VarChar(100) validationAt DateTime? @map("validation_at") @db.DateTime(0) currentLatitude Decimal? @map("current_latitude") @db.Decimal(10, 7) currentLongitude Decimal? @map("current_longitude") @db.Decimal(10, 7) lastLocationAt DateTime? @map("last_location_at") @db.DateTime(0) onthewayStartedAt DateTime? @map("navigation_started_at") @db.DateTime(0) createdAt DateTime? @default(now()) @map("created_at") @db.Timestamp(0) updatedAt DateTime? @updatedAt @map("updated_at") @db.Timestamp(0) ownerRatingStatus Int? @default(0) @map("owner_rating_status") @db.TinyInt providerRatingStatus Int? @default(0) @map("provider_rating_status") @db.TinyInt gigRatings GigRating[] userRole UserRole? @relation(fields: [userRoleId], references: [id], onDelete: NoAction, onUpdate: NoAction) gigServices GigService[] gigEstimates GigEstimate[] gigProviderRequests GigProviderRequest[] gigStatusLogs GigStatusLog[] gigValidations GigValidation[] gigTeamMembers GigTeamMember[] helperGigAttendances HelperGigAttendance[] earningHolds UserEarningHold[] grievances Grievance[] @@index([userRoleId], map: "cg_tbl_gigs_user_role_id_fkey") @@map("cg_tbl_gigs") } model GigReason { id BigInt @id @default(autoincrement()) reason String @db.VarChar(255) status Int? @default(1) @db.TinyInt createdAt DateTime? @default(now()) @map("created_at") @db.Timestamp(0) updatedAt DateTime? @updatedAt @map("updated_at") @db.Timestamp(0) @@map("cg_tbl_gig_reasons") } model GigService { id BigInt @id @default(autoincrement()) gigId BigInt @map("gig_id") categoryId BigInt? @map("category_id") serviceId BigInt? @map("service_id") isEstimate Int @default(0) @map("is_estimate") serviceAmount Decimal? @default(0) @map("service_amount") @db.Decimal(10, 2) discountType String? @map("discount_type") @db.VarChar(50) discountValue Decimal? @default(0) @map("discount_value") @db.Decimal(10, 2) providerPayoutPercentage Decimal @default(100) @map("provider_payout_percentage") @db.Decimal(5, 2) platformHoldPercentage Decimal @default(0) @map("platform_hold_percentage") @db.Decimal(5, 2) holdPeriodHours Int @default(0) @map("hold_period_hours") pickupDropAmount Decimal @default(0.00) @map("pickup_drop_amount") @db.Decimal(10, 2) remarks String? @db.Text createdAt DateTime? @default(now()) @map("created_at") @db.Timestamp(0) updatedAt DateTime? @updatedAt @map("updated_at") @db.Timestamp(0) gig Gig @relation(fields: [gigId], references: [id], onDelete: Cascade) earningHolds UserEarningHold[] @@index([gigId], map: "cg_tbl_gig_services_gig_id_fkey") @@map("cg_tbl_gig_services") } enum EstimatePaymentStatus { pending paid failed } model GigEstimate { id BigInt @id @default(autoincrement()) gigId BigInt @map("gig_id") providerType EstimateProviderType @map("provider_type") providerId BigInt @map("provider_id") estimateDetails Json @map("estimate_details") estimateTotalAmount Decimal @map("estimate_amount") @db.Decimal(10, 2) attachment String? @db.Text notes String? @db.Text status ApprovalStatus @default(pending) paymentStatus EstimatePaymentStatus @default(pending) @map("payment_status") paymentOrderId String? @map("payment_order_id") @db.VarChar(255) paymentTransactionId String? @map("payment_transaction_id") @db.VarChar(255) approvedBy BigInt? @map("approved_by") approvedAt DateTime? @map("approved_at") @db.DateTime(0) createdAt DateTime? @default(now()) @map("created_at") @db.Timestamp(0) updatedAt DateTime? @updatedAt @map("updated_at") @db.Timestamp(0) gig Gig @relation(fields: [gigId], references: [id], onDelete: Cascade) @@index([gigId], map: "cg_tbl_gig_estimates_gig_id_fkey") @@map("cg_tbl_gig_estimates") } enum GigProviderType { garage freelancer helper towing } enum EstimateProviderType { garage freelancer towing } model GigStatusLog { id BigInt @id @default(autoincrement()) gigId BigInt @map("gig_id") oldStatus String? @map("old_status") @db.VarChar(100) newStatus String @map("new_status") @db.VarChar(100) changedById BigInt @map("changed_by_id") changedByRoleId BigInt @map("changed_by_role_id") remarks String? @db.Text platform GigPlatform @map("platform") createdAt DateTime? @default(now()) @map("created_at") @db.Timestamp(0) gig Gig @relation(fields: [gigId], references: [id], onDelete: Cascade) @@index([gigId], map: "cg_tbl_gig_status_logs_gig_id_fkey") @@map("cg_tbl_gig_status_logs") } enum GigPlatform { app web } model GigProviderRequest { id BigInt @id @default(autoincrement()) gigId BigInt @map("gig_id") providerId BigInt @map("provider_id") providerRoleId BigInt @map("provider_role_id") status GigProviderRequestStatus @default(pending) platform GigPlatform @default(app) createdAt DateTime? @map("created_at") @db.DateTime(0) updatedAt DateTime? @map("updated_at") @db.DateTime(0) gig Gig @relation(fields: [gigId], references: [id], onDelete: Cascade, onUpdate: NoAction) providerRole UserRole @relation(fields: [providerRoleId], references: [id], onDelete: NoAction, onUpdate: NoAction) @@index([gigId], map: "cg_tbl_gig_provider_requests_gig_id_fkey") @@index([providerRoleId], map: "cg_tbl_gig_provider_requests_provider_role_id_fkey") @@index([providerId], map: "cg_tbl_gig_provider_requests_provider_id_idx") @@map("cg_tbl_gig_provider_requests") } enum GigProviderRequestStatus { pending accepted rejected } model TempGig { id BigInt @id @default(autoincrement()) userId BigInt @map("user_id") userRoleId BigInt? @map("user_role_id") providerType GigProviderType? @map("provider_type") providerId BigInt? @map("provider_id") vehicleDetails Json? @map("vehicle_details") vehicleCondition Json? @map("vehicle_condition") reasonId BigInt? @map("reason_id") addressDetails Json? @map("address_details") dropAddressDetails Json? @map("drop_address_details") services Json? initialAttachments Json? @map("initial_attachments") amount Decimal? @db.Decimal(10, 2) razorpayOrderId String? @unique @map("razorpay_order_id") paymentStatus String @default("pending") @map("payment_status") description String? @db.Text urgency String? @db.VarChar(50) isAccident Int @default(0) @map("is_accident") @db.TinyInt isScheduled Boolean @default(false) @map("is_scheduled") scheduledAt DateTime? @map("scheduled_at") gigType GigType? @map("gig_type") scheduledEndAt DateTime? @map("scheduled_end_at") @db.Timestamp(0) createdAt DateTime? @default(now()) @map("created_at") @db.Timestamp(0) updatedAt DateTime? @updatedAt @map("updated_at") @db.Timestamp(0) @@map("cg_tbl_temp_gigs") } model GigValidation { id BigInt @id @default(autoincrement()) gigId BigInt @map("gig_id") userId BigInt @map("user_id") status String @db.VarChar(100) comment String? @db.Text images Json? workSummary String? @map("work_summary") @db.Text invoiceDocument String? @map("invoice_document") @db.Text createdAt DateTime? @default(now()) @map("created_at") @db.Timestamp(0) updatedAt DateTime? @updatedAt @map("updated_at") @db.Timestamp(0) gig Gig @relation(fields: [gigId], references: [id], onDelete: Cascade) @@index([gigId], map: "cg_tbl_gig_validations_gig_id_fkey") @@map("cg_tbl_gig_validations") } model UserEarning { id BigInt @id @default(autoincrement()) userId BigInt @map("user_id") userRoleId BigInt @map("user_role_id") totalEarned Decimal @default(0) @map("total_earned") @db.Decimal(12, 2) totalSettled Decimal @default(0) @map("total_settled") @db.Decimal(12, 2) availableBalance Decimal @default(0) @map("available_balance") @db.Decimal(12, 2) holdBalance Decimal @default(0) @map("hold_balance") @db.Decimal(12, 2) platform GigPlatform @default(app) createdAt DateTime? @default(now()) @map("created_at") @db.Timestamp(0) updatedAt DateTime? @updatedAt @map("updated_at") @db.Timestamp(0) userRole UserRole @relation(fields: [userRoleId], references: [id], onDelete: NoAction, onUpdate: NoAction) earningHolds UserEarningHold[] @@index([userId], map: "cg_tbl_user_earnings_user_id_idx") @@index([userRoleId], map: "cg_tbl_user_earnings_user_role_id_fkey") @@index([platform], map: "cg_tbl_user_earnings_platform_idx") @@map("cg_tbl_user_earnings") } enum HoldStatus { ACTIVE UNDER_GRIEVANCE RELEASED DEDUCTED CANCELLED } model UserEarningHold { id BigInt @id @default(autoincrement()) userEarningId BigInt @map("user_earning_id") gigId BigInt @map("gig_id") gigServiceId BigInt? @map("gig_service_id") holdAmount Decimal @default(0) @map("hold_amount") @db.Decimal(12, 2) releasedAmount Decimal @default(0) @map("released_amount") @db.Decimal(12, 2) releaseAt DateTime? @map("release_at") @db.Timestamp(0) releasedAt DateTime? @map("released_at") @db.Timestamp(0) grievanceId BigInt? @map("grievance_id") status HoldStatus @default(ACTIVE) releasedBy BigInt? @map("released_by") remarks String? @db.Text createdAt DateTime? @default(now()) @map("created_at") @db.Timestamp(0) updatedAt DateTime? @updatedAt @map("updated_at") @db.Timestamp(0) userEarning UserEarning @relation(fields: [userEarningId], references: [id], onDelete: Cascade) gig Gig @relation(fields: [gigId], references: [id], onDelete: Cascade) gigService GigService? @relation(fields: [gigServiceId], references: [id], onDelete: SetNull) @@index([userEarningId], map: "cg_tbl_user_earning_holds_user_earning_id_idx") @@index([gigId], map: "cg_tbl_user_earning_holds_gig_id_idx") @@index([gigServiceId], map: "cg_tbl_user_earning_holds_gig_service_id_idx") @@index([status], map: "cg_tbl_user_earning_holds_status_idx") @@index([releaseAt], map: "cg_tbl_user_earning_holds_release_at_idx") @@map("cg_tbl_user_earning_holds") } enum JobStatus { PENDING PROCESSING COMPLETED FAILED DLQ } enum NotificationPriority { CRITICAL HIGH LOW } model OutboxNotification { id BigInt @id @default(autoincrement()) idempotencyKey String @unique @map("idempotency_key") @db.VarChar(255) correlationId String @map("correlation_id") @db.VarChar(50) userId BigInt @map("user_id") userRoleId BigInt @map("user_role_id") channels String @db.VarChar(100) priority NotificationPriority @default(HIGH) title String? @db.VarChar(255) body String @db.Text payload Json? status JobStatus @default(PENDING) retryCount Int @default(0) @map("retry_count") maxRetries Int @default(5) @map("max_retries") nextRetryAt DateTime? @map("next_retry_at") lockedBy String? @map("locked_by") @db.VarChar(100) lockExpiresAt DateTime? @map("lock_expires_at") createdAt DateTime @default(now()) @map("created_at") updatedAt DateTime @updatedAt @map("updated_at") attempts NotificationAttempt[] @@index([status, nextRetryAt, lockExpiresAt]) @@map("cg_tbl_outbox_notifications") } model NotificationAttempt { id BigInt @id @default(autoincrement()) outboxId BigInt @map("outbox_id") correlationId String @map("correlation_id") @db.VarChar(50) channel String @db.VarChar(50) attemptNumber Int @map("attempt_number") status String @db.VarChar(20) latencyMs Int @map("latency_ms") responseLog String? @map("response_log") @db.Text errorMessage String? @map("error_message") @db.Text createdAt DateTime @default(now()) @map("created_at") notification OutboxNotification @relation(fields: [outboxId], references: [id], onDelete: Cascade) @@index([outboxId]) @@map("cg_tbl_notification_attempts") } model DistributedCronJob { id String @id @db.VarChar(100) cronExpr String @map("cron_expr") @db.VarChar(50) status JobStatus @default(PENDING) lockedBy String? @map("locked_by") @db.VarChar(100) lockExpiresAt DateTime? @map("lock_expires_at") lastRunAt DateTime? @map("last_run_at") updatedAt DateTime @updatedAt @map("updated_at") @@map("cg_tbl_distributed_cron_jobs") } model GigTeamMember { id BigInt @id @default(autoincrement()) gigId BigInt freelancerId BigInt teamMemberId BigInt status TeamMemberAssignmentStatus @default(ASSIGNED) assignedAt DateTime @default(now()) removedAt DateTime? remarks String? createdAt DateTime @default(now()) updatedAt DateTime @updatedAt gig Gig @relation(fields: [gigId], references: [id]) @@index([gigId]) @@index([freelancerId]) @@index([teamMemberId]) @@map("cg_tbl_gig_team_members") } enum TeamMemberAssignmentStatus { ASSIGNED @map("assigned") REMOVED @map("removed") } model Refund { id BigInt @id @default(autoincrement()) referenceType RefundReferenceType referenceId BigInt paymentTransactionId BigInt? refundAmount Decimal @db.Decimal(10, 2) refundReason String? customerNote String? adminNote String? requestedBy RefundRequestedBy requestedById BigInt approvedById BigInt? refundMethod RefundMethod? refundMode RefundMode @default(SOURCE) refundStatus RefundStatus @default(PENDING) gatewayRefundId String? gatewayResponse Json? refundedAt DateTime? createdAt DateTime @default(now()) updatedAt DateTime @updatedAt @@index([referenceType, referenceId]) @@index([paymentTransactionId]) @@index([refundStatus]) @@map("cg_tbl_refunds") } enum RefundReferenceType { ORDER ORDER_ITEM GIG INTERNSHIP INTERNSHIP_EXTENSION } enum RefundMode { SOURCE WALLET BANK } enum RefundRequestedBy { USER SELLER ADMIN } enum RefundMethod { DIGITALPAYMENT } enum RefundStatus { PENDING PROCESSING COMPLETED FAILED REJECTED } model HelperGigAttendance { id BigInt @id @default(autoincrement()) gigId BigInt @map("gig_id") helperId BigInt @map("helper_id") attendanceDate DateTime @map("attendance_date") @db.Date punchInAt DateTime? @map("punch_in_at") punchOutAt DateTime? @map("punch_out_at") workedHours Decimal @default(0) @map("worked_hours") @db.Decimal(5, 2) punchInLatitude Decimal? @map("punch_in_latitude") @db.Decimal(10, 8) punchInLongitude Decimal? @map("punch_in_longitude") @db.Decimal(11, 8) punchInAddress String? @map("punch_in_address") @db.Text punchOutLatitude Decimal? @map("punch_out_latitude") @db.Decimal(10, 8) punchOutLongitude Decimal? @map("punch_out_longitude") @db.Decimal(11, 8) punchOutAddress String? @map("punch_out_address") @db.Text createdAt DateTime @default(now()) @map("created_at") updatedAt DateTime @updatedAt @map("updated_at") gig Gig @relation(fields: [gigId], references: [id]) @@index([gigId]) @@index([gigId, attendanceDate]) @@map("cg_tbl_helper_gig_attendance") } enum Platform { app web } enum OrderStatus { pending confirmed ready_to_ship shipped out_for_delivery delivered cancelled failed } enum OrderItemStatus { pending confirmed rejected } enum HelperEarlyLeaveStatus { pending approved rejected } enum GrievanceStatus { raised assigned inprogress waiting_for_approval resolved rejected escalated } model Order { id BigInt @id @default(autoincrement()) orderNo String @unique @map("order_no") @db.VarChar(100) userId BigInt @map("user_id") userRoleId BigInt @map("user_role_id") sellerId BigInt @map("seller_id") zoneId BigInt @map("zone_id") addressDetails Json @map("address_details") couponCode String? @map("coupon_code") @db.VarChar(255) subtotal Decimal @db.Decimal(12, 2) discountAmount Decimal @default(0) @map("discount_amount") @db.Decimal(12, 2) taxAmount Decimal @default(0) @map("tax_amount") @db.Decimal(12, 2) deliveryCharge Decimal @default(0) @map("delivery_charge") @db.Decimal(12, 2) commissionPercentage Decimal @default(0) @map("commission_percentage") @db.Decimal(5, 2) commissionAmount Decimal @default(0) @map("commission_amount") @db.Decimal(12, 2) commissionGstPercentage Decimal? @default(0) @map("commission_gst_percentage") @db.Decimal(5, 2) commissionGstAmount Decimal? @default(0) @map("commission_gst_amount") @db.Decimal(12, 2) tcsPercentage Decimal? @default(0) @map("tcs_percentage") @db.Decimal(5, 2) tcsAmount Decimal? @default(0) @map("tcs_amount") @db.Decimal(12, 2) tdsPercentage Decimal? @default(0) @map("tds_percentage") @db.Decimal(5, 2) tdsAmount Decimal? @default(0) @map("tds_amount") @db.Decimal(12, 2) otherChargesLabel String? @map("other_charges_label") @db.VarChar(255) otherChargesType String? @map("other_charges_type") @db.VarChar(50) otherChargesValue Decimal? @map("other_charges_value") @db.Decimal(10, 2) otherChargesAmount Decimal? @default(0) @map("other_charges_amount") @db.Decimal(12, 2) settlementAmount Decimal @default(0) @map("settlement_amount") @db.Decimal(12, 2) grandTotal Decimal @map("grand_total") @db.Decimal(12, 2) paymentMethod String @map("payment_method") @db.VarChar(100) paymentGateway String @map("payment_gateway") @db.VarChar(100) paymentStatus PaymentStatus @default(pending) @map("payment_status") transactionId String? @map("transaction_id") @db.VarChar(255) platform Platform orderStatus OrderStatus @default(pending) @map("order_status") gstNumber String? @map("gst_number") @db.VarChar(20) notes String? @db.Text adminContributionPercentage Int? @default(0) @map("admin_contribution_percentage") vendorContributionPercentage Int? @default(0) @map("vendor_contribution_percentage") couponDiscountAmount Decimal @default(0) @map("coupon_discount_amount") @db.Decimal(12, 2) couponDiscountTitle String? @map("coupon_discount_title") @db.VarChar(255) cancelledBy String? @map("cancelled_by") @db.VarChar(50) orderType OrderType @default(normal) @map("order_type") customerPayableAmount Decimal @default(0) @map("customer_payable_amount") @db.Decimal(12, 2) createdAt DateTime? @default(now()) @map("created_at") @db.Timestamp(0) updatedAt DateTime? @updatedAt @map("updated_at") @db.Timestamp(0) parentOrderId BigInt? @map("parent_order_id") parentOrder Order? @relation("OrderReplacements", fields: [parentOrderId], references: [id], onDelete: SetNull, onUpdate: Cascade) replacementOrders Order[] @relation("OrderReplacements") returnRequests OrderItemReturnRequest[] facilityRating OrderFacilityRating? sellerRating SellerRating? productRatings ProductRating[] @@map("cg_tbl_orders") } model OrderItem { id BigInt @id @default(autoincrement()) orderId BigInt @map("order_id") productId BigInt @map("product_id") quantity Int mrp Decimal @db.Decimal(12, 2) sellingPrice Decimal @map("selling_price") @db.Decimal(12, 2) discountType DiscountType? @map("discount_type") discountValue Decimal? @map("discount_value") @db.Decimal(12, 2) discountAmount Decimal? @default(0) @map("discount_amount") @db.Decimal(12, 2) finalPrice Decimal @default(0) @map("final_price") @db.Decimal(12, 2) taxPercentage Decimal @default(0) @map("tax_percentage") @db.Decimal(5, 2) taxAmount Decimal @default(0) @map("tax_amount") @db.Decimal(12, 2) totalAmount Decimal @map("total_amount") @db.Decimal(12, 2) couponDiscountAmount Decimal @default(0) @map("coupon_discount_amount") @db.Decimal(10, 2) status OrderItemStatus @default(pending) rejectionReason String? @map("rejection_reason") @db.Text remarks String? @db.Text cancelledBy String? @map("cancelled_by") @db.VarChar(50) createdAt DateTime? @default(now()) @map("created_at") @db.Timestamp(0) updatedAt DateTime? @updatedAt @map("updated_at") @db.Timestamp(0) deliveredAt DateTime? @map("delivered_at") @db.Timestamp(0) isReturnRequested Int @default(0) @map("is_return_requested") @db.TinyInt refundEligibleAmount Decimal @default(0) @map("refund_eligible_amount") @db.Decimal(12, 2) commissionAmount Decimal @default(0) @map("commission_amount") @db.Decimal(12, 2) settlementAmount Decimal @default(0) @map("settlement_amount") @db.Decimal(12, 2) originalOrderItemId BigInt? @map("original_order_item_id") originalOrderItem OrderItem? @relation("OrderItemReplacements", fields: [originalOrderItemId], references: [id], onDelete: SetNull, onUpdate: Cascade) replacementItems OrderItem[] @relation("OrderItemReplacements") productRating ProductRating? returnRequests OrderItemReturnRequest[] @@map("cg_tbl_order_items") } model OrderLog { id BigInt @id @default(autoincrement()) orderId BigInt @map("order_id") orderItemId BigInt? @map("order_item_id") status String @db.VarChar(100) remarks String? @db.Text createdBy BigInt? @map("created_by") createdAt DateTime? @default(now()) @map("created_at") @db.Timestamp(0) @@map("cg_tbl_order_logs") } model TempOrder { id BigInt @id @default(autoincrement()) orderNo String @unique @map("order_no") @db.VarChar(100) userId BigInt @map("user_id") userRoleId BigInt @map("user_role_id") sellerId BigInt @map("seller_id") zoneId BigInt @map("zone_id") addressDetails Json @map("address_details") couponCode String? @map("coupon_code") @db.VarChar(255) subtotal Decimal @db.Decimal(12, 2) discountAmount Decimal @default(0) @map("discount_amount") @db.Decimal(12, 2) taxAmount Decimal @default(0) @map("tax_amount") @db.Decimal(12, 2) deliveryCharge Decimal @default(0) @map("delivery_charge") @db.Decimal(12, 2) commissionPercentage Decimal @default(0) @map("commission_percentage") @db.Decimal(5, 2) commissionAmount Decimal @default(0) @map("commission_amount") @db.Decimal(12, 2) commissionGstPercentage Decimal? @default(0) @map("commission_gst_percentage") @db.Decimal(5, 2) commissionGstAmount Decimal? @default(0) @map("commission_gst_amount") @db.Decimal(12, 2) tcsPercentage Decimal? @default(0) @map("tcs_percentage") @db.Decimal(5, 2) tcsAmount Decimal? @default(0) @map("tcs_amount") @db.Decimal(12, 2) tdsPercentage Decimal? @default(0) @map("tds_percentage") @db.Decimal(5, 2) tdsAmount Decimal? @default(0) @map("tds_amount") @db.Decimal(12, 2) grandTotal Decimal @map("grand_total") @db.Decimal(12, 2) paymentMethod String @map("payment_method") @db.VarChar(100) paymentGateway String @map("payment_gateway") @db.VarChar(100) razorpayOrderId String? @map("razorpay_order_id") @db.VarChar(255) platform Platform gstNumber String? @map("gst_number") @db.VarChar(20) expiresAt DateTime @map("expires_at") @db.Timestamp(0) adminContributionPercentage Int? @default(0) @map("admin_contribution_percentage") vendorContributionPercentage Int? @default(0) @map("vendor_contribution_percentage") couponDiscountAmount Decimal @default(0) @map("coupon_discount_amount") @db.Decimal(12, 2) couponDiscountTitle String? @map("coupon_discount_title") @db.VarChar(255) createdAt DateTime? @default(now()) @map("created_at") @db.Timestamp(0) updatedAt DateTime? @updatedAt @map("updated_at") @db.Timestamp(0) @@map("cg_tbl_temp_orders") } model TempOrderItem { id BigInt @id @default(autoincrement()) tempOrderId BigInt @map("temp_order_id") productId BigInt @map("product_id") quantity Int mrp Decimal @db.Decimal(12, 2) sellingPrice Decimal @map("selling_price") @db.Decimal(12, 2) discountType DiscountType? @map("discount_type") discountValue Decimal? @map("discount_value") @db.Decimal(12, 2) discountAmount Decimal? @default(0) @map("discount_amount") @db.Decimal(12, 2) finalPrice Decimal @default(0) @map("final_price") @db.Decimal(12, 2) taxPercentage Decimal @default(0) @map("tax_percentage") @db.Decimal(5, 2) taxAmount Decimal @default(0) @map("tax_amount") @db.Decimal(12, 2) totalAmount Decimal @map("total_amount") @db.Decimal(12, 2) couponDiscountAmount Decimal @default(0) @map("coupon_discount_amount") @db.Decimal(10, 2) createdAt DateTime? @default(now()) @map("created_at") @db.Timestamp(0) updatedAt DateTime? @updatedAt @map("updated_at") @db.Timestamp(0) @@map("cg_tbl_temp_order_items") } model AdvertisementConfig { id BigInt @id @default(autoincrement()) @db.UnsignedBigInt name String @db.VarChar(255) type AdvertisementType perDayPrice Decimal @map("per_day_price") @db.Decimal(10, 2) // ["all"] = all zones selected | ["1","2","3"] = specific zone IDs selected manually zones String @db.Text status Int @default(1) @db.TinyInt createdBy BigInt? @map("created_by") createdByUser AdminUser? @relation(fields: [createdBy], references: [id], onDelete: NoAction, onUpdate: NoAction) createdAt DateTime @default(now()) @map("created_at") @db.Timestamp(0) updatedAt DateTime? @updatedAt @map("updated_at") @db.Timestamp(0) @@index([type]) @@index([status]) @@index([createdBy]) @@map("cg_tbl_advertisement_config") } model HelperEarlyLeaveRequest { id BigInt @id @default(autoincrement()) gigId BigInt @map("gig_id") helperId BigInt @map("helper_id") reason String? @db.Text status HelperEarlyLeaveStatus @default(pending) originalGigType GigType @map("original_gig_type") convertedGigType GigType? @map("converted_gig_type") originalBaseAmount Decimal? @map("original_base_amount") @db.Decimal(10, 2) originalGrossAmount Decimal? @map("original_gross_amount") @db.Decimal(10, 2) originalPayableAmount Decimal? @map("original_payable_amount") @db.Decimal(10, 2) convertedBaseAmount Decimal? @map("converted_base_amount") @db.Decimal(10, 2) convertedGrossAmount Decimal? @map("converted_gross_amount") @db.Decimal(10, 2) convertedPayableAmount Decimal? @map("converted_payable_amount") @db.Decimal(10, 2) refundAmount Decimal? @map("refund_amount") @db.Decimal(10, 2) createdAt DateTime @default(now()) @map("created_at") updatedAt DateTime @updatedAt @map("updated_at") @@map("cg_tbl_helper_early_leave_requests") } model Grievance { id BigInt @id @default(autoincrement()) grievanceNo String @unique @map("grievance_no") @db.VarChar(100) gigId BigInt? @map("gig_id") raisedById BigInt @map("raised_by_id") raisedByRoleId BigInt @map("raised_by_role_id") originalProviderId BigInt @map("original_provider_id") originalProviderRoleId BigInt @map("original_provider_role_id") assignedProviderId BigInt? @map("assigned_provider_id") assignedProviderRoleId BigInt? @map("assigned_provider_role_id") status GrievanceStatus @default(raised) complaintType String @map("complaint_type") @db.VarChar(50) estimatedCost Decimal? @map("estimated_cost") @db.Decimal(12, 2) approvedCost Decimal? @map("approved_cost") @db.Decimal(12, 2) customerRemarks String? @map("customer_remarks") @db.Text customerImages Json? @map("customer_images") // JSON Array of image urls providerRemarks String? @map("provider_remarks") @db.Text providerImages Json? @map("provider_images") // Resolution photos providerDocuments Json? @map("provider_documents") // Invoices or proof docs adminRemarks String? @map("admin_remarks") @db.Text disputed Boolean @default(false) @map("disputed") disputeReason String? @map("dispute_reason") @db.Text createdAt DateTime @default(now()) @map("created_at") updatedAt DateTime @updatedAt @map("updated_at") gig Gig? @relation(fields: [gigId], references: [id], onDelete: Cascade) raisedByRole UserRole @relation("GrievanceRaisedRole", fields: [raisedByRoleId], references: [id], onDelete: NoAction, onUpdate: NoAction) originalProviderRole UserRole @relation("GrievanceOriginalRole", fields: [originalProviderRoleId], references: [id], onDelete: NoAction, onUpdate: NoAction) assignedProviderRole UserRole? @relation("GrievanceAssignedRole", fields: [assignedProviderRoleId], references: [id], onDelete: NoAction, onUpdate: NoAction) history GrievanceHistory[] @@index([raisedByRoleId]) @@index([originalProviderRoleId]) @@index([assignedProviderRoleId]) @@map("cg_tbl_grievances") } model GrievanceHistory { id BigInt @id @default(autoincrement()) grievanceId BigInt @map("grievance_id") fromStatus GrievanceStatus @map("from_status") toStatus GrievanceStatus @map("to_status") changedById BigInt @map("changed_by_id") changedByRoleId BigInt @map("changed_by_role_id") remarks String? @db.Text platform GigPlatform @default(app) createdAt DateTime @default(now()) @map("created_at") assignedProviderId BigInt? @map("assigned_provider_id") assignedProviderRoleId BigInt? @map("assigned_provider_role_id") providerRemarks String? @map("provider_remarks") @db.Text providerImages String? @map("provider_images") @db.Text providerDocuments String? @map("provider_documents") @db.Text estimatedCost Decimal? @map("estimated_cost") @db.Decimal(10, 2) grievance Grievance @relation(fields: [grievanceId], references: [id], onDelete: Cascade) @@map("cg_tbl_grievance_histories") } // ========================================== // RETURN, EXCHANGE AND CANCELLATION MODELS & ENUMS // ========================================== enum OrderType { normal replacement } enum OrderItemRequestStatus { pending approved rejected pickup_dispatched received refund_initiated refunded completed } enum OrderResolutionType { refund exchange } model ReturnReason { id BigInt @id @default(autoincrement()) reason String @db.VarChar(255) status Int? @default(1) @db.TinyInt createdAt DateTime? @default(now()) @map("created_at") @db.Timestamp(0) updatedAt DateTime? @updatedAt @map("updated_at") @db.Timestamp(0) returnRequests OrderItemReturnRequest[] @@map("cg_tbl_return_reasons") } model OrderItemReturnRequest { id BigInt @id @default(autoincrement()) orderId BigInt @map("order_id") orderItemId BigInt @map("order_item_id") raisedById BigInt @map("raised_by_id") raisedByRoleId BigInt @map("raised_by_role_id") sellerId BigInt @map("seller_id") reasonId BigInt @map("reason_id") description String? @db.Text images Json? @map("images") status OrderItemRequestStatus @default(pending) resolutionType OrderResolutionType? @map("resolution_type") rejectionReason String? @map("rejection_reason") @db.Text creditNoteFile String? @map("credit_note_file") @db.VarChar(255) replacementOrderId BigInt? @map("replacement_order_id") createdAt DateTime? @default(now()) @map("created_at") @db.Timestamp(0) updatedAt DateTime? @updatedAt @map("updated_at") @db.Timestamp(0) order Order @relation(fields: [orderId], references: [id], onDelete: Cascade) orderItem OrderItem @relation(fields: [orderItemId], references: [id], onDelete: Cascade) reasonReturn ReturnReason @relation(fields: [reasonId], references: [id], onDelete: Cascade) history OrderItemReturnHistory[] @@index([orderId]) @@index([orderItemId]) @@index([sellerId]) @@index([reasonId]) @@map("cg_tbl_order_item_return_requests") } model OrderItemReturnHistory { id BigInt @id @default(autoincrement()) requestId BigInt @map("request_id") fromStatus String @db.VarChar(50) toStatus String @db.VarChar(50) remarks String? @db.Text changedBy BigInt @map("changed_by") changedByRole BigInt @map("changed_by_role") platform String @default("app") @db.VarChar(50) createdAt DateTime @default(now()) @map("created_at") @db.Timestamp(0) returnRequest OrderItemReturnRequest @relation(fields: [requestId], references: [id], onDelete: Cascade) @@index([requestId]) @@map("cg_tbl_order_item_return_histories") } // Lowercase Enums used by the Settlement model enum SettlementType { default instant } enum ChargeType { flat percentage } enum SettlementStatus { pending approved processed completed rejected failed } enum RequestedBy { user admin } model Settlement { id BigInt @id @default(autoincrement()) settlementNo String @unique @map("settlement_no") @db.VarChar(100) userId BigInt @map("user_id") userRoleId BigInt @map("user_role_id") requestedById BigInt? @map("requested_by_id") // Who raised the request ('user' or 'admin') requestedBy RequestedBy @default(user) @map("requested_by") // Origin Platform ('app' or 'web') platform Platform @map("platform") // Target Bank Details Snapshot bankName String @map("bank_name") @db.VarChar(150) bankAccountNumber String @map("bank_account_number") @db.VarChar(50) bankIfscCode String @map("bank_ifsc_code") @db.VarChar(20) settlementType SettlementType @default(default) @map("settlement_type") // Financial amounts amount Decimal @map("amount") @db.Decimal(12, 2) // Bank Charges (if applicable) bankChargeType ChargeType? @map("bank_charge_type") bankChargeValue Decimal? @map("bank_charge_value") @db.Decimal(12, 2) bankChargeAmount Decimal? @map("bank_charge_amount") @db.Decimal(12, 2) // Instant Settlement Charges (if applicable) instantChargeType ChargeType? @map("instant_charge_type") instantChargeValue Decimal? @map("instant_charge_value") @db.Decimal(12, 2) instantChargeAmount Decimal? @map("instant_charge_amount") @db.Decimal(12, 2) // Final amount transferred to the user bank account after deductions finalAmount Decimal @map("final_amount") @db.Decimal(12, 2) status SettlementStatus @map("status") remarks String? @map("remarks") @db.Text // Timestamps for audit & flow progression requestedAt DateTime @default(now()) @map("requested_at") @db.Timestamp(0) approvedAt DateTime? @map("approved_at") @db.Timestamp(0) processedAt DateTime? @map("processed_at") @db.Timestamp(0) completedAt DateTime? @map("completed_at") @db.Timestamp(0) rejectedAt DateTime? @map("rejected_at") @db.Timestamp(0) // System Audit & Gateway Tracking approvedBy BigInt? @map("approved_by") payoutId String? @map("payout_id") @db.VarChar(255) // Reference from payment gateway utrNumber String? @map("utr_number") @db.VarChar(255) // Unique Transaction Reference failureReason String? @map("failure_reason") @db.Text createdAt DateTime @default(now()) @map("created_at") @db.Timestamp(0) updatedAt DateTime? @updatedAt @map("updated_at") @db.Timestamp(0) // Relations (mapped to the Role table in your schema) userRole UserRole @relation(fields: [userRoleId], references: [id], onDelete: NoAction, onUpdate: NoAction) @@index([userId]) @@index([userRoleId]) @@map("cg_tbl_settlements") } enum InternshipType { paid unpaid } enum InternshipRequestStatus { pending // Sent to intern, awaiting response accepted // Intern accepted active // Internship period active rejected // Intern manually rejected or system auto-rejected completed // Internship period ended cancelled // Cancelled by garage or admin relieved // Intern early relieved/terminated by garage reassigned refund_requested refund_approved // Admin approved the refund request refund_rejected // Admin denied the refund request refunded } enum InternshipExtensionInitiator { garage intern } enum InternshipExtensionStatus { pending // Extension proposal raised, awaiting other party response approved // Accepted by the other party rejected // Rejected by the other party active // Extension period running completed // Extension period ended cancelled reassigned refund_requested refund_approved // Admin approved the refund request refund_rejected // Admin denied the refund request refunded } enum InternshipPaymentReleaseStatus { pending // Admin initiated, under review approved // Admin approved, amount calculated processing // Transfer in progress completed // Credited to intern wallet failed } enum InternshipPaymentReleaseType { monthly relieve } enum InternshipRelieveStatus { pending approved rejected } enum InternshipBatchStatus { open active completed cancelled } model InternshipBatch { id BigInt @id @default(autoincrement()) batchNumber String @unique @map("batch_number") @db.VarChar(50) garageId BigInt @map("garage_id") description String? @db.Text internshipType InternshipType @map("internship_type") // Duration (shared across all requests in this batch) durationMonths Int @map("duration_months") startDate DateTime @map("start_date") @db.Date expectedEndDate DateTime @map("expected_end_date") @db.Date // Financials (for paid type) // total_amount = SUM of all per-intern allocated amounts totalInternCount Int @default(0) @map("total_intern_count") totalAmount Decimal @default(0) @map("total_amount") @db.Decimal(10, 2) // Payment // Values: not_required | pending | completed | failed paymentStatus String @default("not_required") @map("payment_status") @db.VarChar(50) paymentOrderId String? @map("payment_order_id") @db.VarChar(255) paymentTransactionId String? @map("payment_transaction_id") @db.VarChar(255) gatewayName String? @map("gateway_name") @db.VarChar(100) paidAt DateTime? @map("paid_at") @db.Timestamp(0) status InternshipBatchStatus @default(open) createdBy BigInt @map("created_by") createdAt DateTime @default(now()) @map("created_at") @db.Timestamp(0) updatedAt DateTime? @updatedAt @map("updated_at") @db.Timestamp(0) requests InternshipRequest[] statusLogs InternshipStatusLog[] leaves InternshipLeave[] @@index([garageId]) @@index([status]) @@map("cg_tbl_internship_batches") } model InternshipRequest { id BigInt @id @default(autoincrement()) batchId BigInt @map("batch_id") garageId BigInt @map("garage_id") internId BigInt @map("intern_id") serviceId BigInt @map("service_id") // Service this intern was selected for (Painting, Mechanic, etc.) // Extension chain (null for original) parentRequestId BigInt? @map("parent_request_id") isExtension Boolean @default(false) @map("is_extension") extensionNumber Int @default(0) @map("extension_number") // 0 = original, 1 = first extension, 2 = second, ... // Period internshipType InternshipType @map("internship_type") durationMonths Int @map("duration_months") startDate DateTime @map("start_date") @db.Date endDate DateTime @map("end_date") @db.Date actualStartDate DateTime? @map("actual_start_date") @db.Date // Set on acceptance actualEndDate DateTime? @map("actual_end_date") @db.Date // Set on completion // Financials (snapshot at request creation time) monthlyStipend Decimal @default(0) @map("monthly_stipend") @db.Decimal(10, 2) totalAllocatedAmount Decimal @default(0) @map("total_allocated_amount") @db.Decimal(10, 2) totalReleasedAmount Decimal @default(0) @map("total_released_amount") @db.Decimal(10, 2) // Escrow hold reference (Transaction.id of the per-intern escrow DEBIT) holdTransactionId BigInt? @map("hold_transaction_id") // Status & lifecycle timestamps status InternshipRequestStatus @default(pending) respondedAt DateTime? @map("responded_at") @db.Timestamp(0) expiresAt DateTime? @map("expires_at") @db.Timestamp(0) // Auto-reject deadline completedAt DateTime? @map("completed_at") @db.Timestamp(0) cancelledAt DateTime? @map("cancelled_at") @db.Timestamp(0) cancelReason String? @map("cancel_reason") @db.Text cancelledBy String? @map("cancelled_by") @db.VarChar(50) // garage|intern|admin|system otp String? @db.VarChar(10) otpVerified Int @default(0) @map("otp_verified") @db.TinyInt // Relieve request fields (intern-initiated, garage-approved) relieveRequestedAt DateTime? @map("relieve_requested_at") @db.Timestamp(0) relieveDate DateTime? @map("relieve_date") @db.Date relieveReason String? @map("relieve_reason") @db.Text relieveStatus InternshipRelieveStatus? @map("relieve_status") relieveRemarks String? @map("relieve_remarks") @db.Text // Remarks from garage on response // Auto-rejection flag (0 = manual rejection by intern, 1 = system auto-rejected on timeout) isAutoRejected Int @default(0) @map("is_auto_rejected") @db.TinyInt // Post-rejection action: reassign | refund | admin_assign | pending rejectionReason String? @map("rejection_reason") @db.Text postRejectionAction String? @map("post_rejection_action") @db.VarChar(50) // Admin tracking assignedByAdminId BigInt? @map("assigned_by_admin_id") createdAt DateTime @default(now()) @map("created_at") @db.Timestamp(0) updatedAt DateTime? @updatedAt @map("updated_at") @db.Timestamp(0) batch InternshipBatch @relation(fields: [batchId], references: [id]) parentRequest InternshipRequest? @relation("ExtensionChain", fields: [parentRequestId], references: [id]) childRequests InternshipRequest[] @relation("ExtensionChain") attendances InternshipAttendance[] paymentReleases InternshipPaymentRelease[] extensions InternshipExtension[] statusLogs InternshipStatusLog[] leaves InternshipLeave[] @@index([batchId]) @@index([garageId]) @@index([internId]) @@index([serviceId]) @@index([parentRequestId]) @@index([status]) @@index([expiresAt]) @@map("cg_tbl_internship_requests") } model InternshipAttendance { id BigInt @id @default(autoincrement()) requestId BigInt @map("request_id") internId BigInt @map("intern_id") attendanceDate DateTime @map("attendance_date") @db.Date punchInAt DateTime? @map("punch_in_at") punchOutAt DateTime? @map("punch_out_at") workedHours Decimal @default(0) @map("worked_hours") @db.Decimal(5, 2) punchInLatitude Decimal? @map("punch_in_latitude") @db.Decimal(10, 8) punchInLongitude Decimal? @map("punch_in_longitude") @db.Decimal(11, 8) punchInAddress String? @map("punch_in_address") @db.Text punchOutLatitude Decimal? @map("punch_out_latitude") @db.Decimal(10, 8) punchOutLongitude Decimal? @map("punch_out_longitude") @db.Decimal(11, 8) punchOutAddress String? @map("punch_out_address") @db.Text remarks String? @db.Text createdAt DateTime @default(now()) @map("created_at") @db.Timestamp(0) updatedAt DateTime? @updatedAt @map("updated_at") @db.Timestamp(0) request InternshipRequest @relation(fields: [requestId], references: [id]) @@index([requestId]) @@index([internId]) @@index([attendanceDate]) @@map("cg_tbl_internship_attendance") } model InternshipPaymentRelease { id BigInt @id @default(autoincrement()) requestId BigInt @map("request_id") internId BigInt @map("intern_id") garageId BigInt @map("garage_id") releaseMonth Int @map("release_month") // 1–12 releaseYear Int @map("release_year") periodStartDate DateTime @map("period_start_date") @db.Date periodEndDate DateTime @map("period_end_date") @db.Date // Attendance summary totalWorkingDays Int @default(0) @map("total_working_days") // Scheduled working days in the month attendedDays Int @default(0) @map("attended_days") // Total days with successful punch records attendancePercent Decimal @default(0) @map("attendance_percent") @db.Decimal(5, 2) // Financial grossStipend Decimal @map("gross_stipend") @db.Decimal(10, 2) deductionAmount Decimal @default(0) @map("deduction_amount") @db.Decimal(10, 2) netPayableAmount Decimal @map("net_payable_amount") @db.Decimal(10, 2) tdsPercentage Decimal @default(0) @map("tds_percentage") @db.Decimal(5, 2) tdsAmount Decimal @default(0) @map("tds_amount") @db.Decimal(10, 2) netAfterTds Decimal @default(0) @map("net_after_tds") @db.Decimal(10, 2) releaseType InternshipPaymentReleaseType @default(monthly) @map("release_type") adminNote String? @map("admin_note") @db.Text status InternshipPaymentReleaseStatus @default(pending) initiatedById BigInt? @map("initiated_by_id") approvedById BigInt? @map("approved_by_id") approvedAt DateTime? @map("approved_at") @db.Timestamp(0) completedAt DateTime? @map("completed_at") @db.Timestamp(0) failureReason String? @map("failure_reason") @db.Text // Reference to the wallet CREDIT transaction created on completion creditTransactionId BigInt? @map("credit_transaction_id") createdAt DateTime @default(now()) @map("created_at") @db.Timestamp(0) updatedAt DateTime? @updatedAt @map("updated_at") @db.Timestamp(0) request InternshipRequest @relation(fields: [requestId], references: [id]) @@unique([requestId, releaseMonth, releaseYear]) @@index([requestId]) @@index([internId]) @@index([status]) @@map("cg_tbl_internship_payment_releases") } model InternshipExtension { id BigInt @id @default(autoincrement()) extensionNumber String @unique @map("extension_number") @db.VarChar(50) originalRequestId BigInt @map("original_request_id") initiatedBy InternshipExtensionInitiator @map("initiated_by") initiatedById BigInt @map("initiated_by_id") requestedDurationMonths Int @map("requested_duration_months") requestedReason String? @map("requested_reason") @db.Text internshipType InternshipType @map("internship_type") monthlyStipend Decimal @default(0) @map("monthly_stipend") @db.Decimal(10, 2) startDate DateTime? @map("start_date") @db.Date endDate DateTime? @map("end_date") @db.Date status InternshipExtensionStatus @default(pending) reviewedById BigInt? @map("reviewed_by_id") reviewedAt DateTime? @map("reviewed_at") @db.Timestamp(0) reviewNote String? @map("review_note") @db.Text // Payment (for paid extensions) paymentStatus String? @map("payment_status") @db.VarChar(50) paymentOrderId String? @map("payment_order_id") @db.VarChar(255) paymentTransactionId String? @map("payment_transaction_id") @db.VarChar(255) paidAt DateTime? @map("paid_at") @db.Timestamp(0) // Populated once extension is accepted — links to the new child InternshipRequest and its new InternshipBatch childRequestId BigInt? @unique @map("child_request_id") childBatchId BigInt? @unique @map("child_batch_id") expiresAt DateTime? @map("expires_at") @db.Timestamp(0) createdAt DateTime @default(now()) @map("created_at") @db.Timestamp(0) updatedAt DateTime? @updatedAt @map("updated_at") @db.Timestamp(0) originalRequest InternshipRequest @relation(fields: [originalRequestId], references: [id]) @@index([originalRequestId]) @@index([status]) @@map("cg_tbl_internship_extensions") } model InternshipStatusLog { id BigInt @id @default(autoincrement()) batchId BigInt? @map("batch_id") requestId BigInt? @map("request_id") performedById BigInt @map("performed_by_id") performedByType String @map("performed_by_type") @db.VarChar(50) // garage | intern | admin | system oldStatus String? @map("old_status") @db.VarChar(100) newStatus String? @map("new_status") @db.VarChar(100) remarks String? @db.Text metadata Json? // Additional contextual data platform String @default("app") @db.VarChar(20) createdAt DateTime @default(now()) @map("created_at") @db.Timestamp(0) batch InternshipBatch? @relation(fields: [batchId], references: [id]) request InternshipRequest? @relation(fields: [requestId], references: [id]) @@index([batchId]) @@index([requestId]) @@index([performedById, performedByType]) @@map("cg_tbl_internship_status_logs") } model TempInternship { id BigInt @id @default(autoincrement()) garageId BigInt @map("garage_id") createdBy BigInt? @map("created_by") description String? @db.Text internshipType InternshipType @map("internship_type") durationMonths Int @map("duration_months") startDate DateTime @map("start_date") @db.Date expectedEndDate DateTime @map("expected_end_date") @db.Date // Selected interns: JSON array containing { internId, serviceId, monthlyStipend } interns Json @db.Json totalInternCount Int @map("total_intern_count") totalAmount Decimal @map("total_amount") @db.Decimal(10, 2) razorpayOrderId String? @unique @map("razorpay_order_id") gatewayName String? @map("gateway_name") @db.VarChar(100) paymentStatus String @default("pending") @map("payment_status") @db.VarChar(50) createdAt DateTime @default(now()) @map("created_at") @db.Timestamp(0) updatedAt DateTime? @updatedAt @map("updated_at") @db.Timestamp(0) @@map("cg_tbl_temp_internships") } model InternshipLeave { id BigInt @id @default(autoincrement()) requestId BigInt @map("request_id") batchId BigInt @map("batch_id") internId BigInt @map("intern_id") garageId BigInt @map("garage_id") status InternLeaveStatus @default(pending) startDate DateTime @map("start_date") @db.Date endDate DateTime @map("end_date") @db.Date totalDays Int @map("total_days") @db.Int reason String? @db.Text reviewNote String? @map("review_note") @db.Text reviewedById BigInt? @map("reviewed_by_id") reviewedAt DateTime? @map("reviewed_at") @db.Timestamp(0) createdAt DateTime @default(now()) @map("created_at") @db.Timestamp(0) updatedAt DateTime? @updatedAt @map("updated_at") @db.Timestamp(0) request InternshipRequest @relation(fields: [requestId], references: [id]) batch InternshipBatch @relation(fields: [batchId], references: [id]) @@index([requestId]) @@index([internId]) @@index([garageId]) @@index([status]) @@map("cg_tbl_internship_leaves") } enum InternLeaveStatus { pending approved rejected cancelled } model OrderFacilityRating { id BigInt @id @default(autoincrement()) orderId BigInt @unique @map("order_id") userId BigInt @map("user_id") userRoleId BigInt @map("user_role_id") rating Int @db.TinyInt standardReasons Json? @map("standard_reasons") comment String? @db.Text createdAt DateTime? @default(now()) @map("created_at") updatedAt DateTime? @updatedAt @map("updated_at") order Order @relation(fields: [orderId], references: [id], onDelete: Cascade) userRole UserRole @relation(fields: [userRoleId], references: [id], onDelete: Cascade) @@index([userId, userRoleId]) @@map("cg_tbl_order_facility_ratings") } model SellerRating { id BigInt @id @default(autoincrement()) orderId BigInt @unique @map("order_id") userId BigInt @map("user_id") userRoleId BigInt @map("user_role_id") sellerId BigInt @map("seller_id") rating Int @db.TinyInt standardReasons Json? @map("standard_reasons") comment String? @db.Text createdAt DateTime? @default(now()) @map("created_at") updatedAt DateTime? @updatedAt @map("updated_at") order Order @relation(fields: [orderId], references: [id], onDelete: Cascade) seller Seller @relation(fields: [sellerId], references: [id], onDelete: Cascade) userRole UserRole @relation(fields: [userRoleId], references: [id], onDelete: Cascade) @@index([sellerId]) @@index([userId, userRoleId]) @@map("cg_tbl_seller_ratings") } model ProductRating { id BigInt @id @default(autoincrement()) orderId BigInt @map("order_id") orderItemId BigInt @unique @map("order_item_id") productId BigInt @map("product_id") @db.UnsignedBigInt sellerId BigInt @map("seller_id") userId BigInt @map("user_id") userRoleId BigInt @map("user_role_id") rating Int @db.TinyInt standardReasons Json? @map("standard_reasons") comment String? @db.Text images Json? status Int @default(1) @db.TinyInt createdAt DateTime? @default(now()) @map("created_at") updatedAt DateTime? @updatedAt @map("updated_at") order Order @relation(fields: [orderId], references: [id], onDelete: Cascade) orderItem OrderItem @relation(fields: [orderItemId], references: [id], onDelete: Cascade) product Product @relation(fields: [productId], references: [id], onDelete: Cascade) seller Seller @relation(fields: [sellerId], references: [id], onDelete: Cascade) userRole UserRole @relation(fields: [userRoleId], references: [id], onDelete: Cascade) @@index([productId]) @@index([sellerId]) @@index([userId, userRoleId]) @@map("cg_tbl_product_ratings") } model GigRating { id BigInt @id @default(autoincrement()) gigId BigInt @map("gig_id") ratedBy String @map("rated_by") @db.VarChar(50) ownerId BigInt @map("owner_id") ownerRoleId BigInt @map("owner_role_id") providerId BigInt @map("provider_id") providerRoleId BigInt @map("provider_role_id") qualityRating Int @map("quality_rating") @db.TinyInt timelinessRating Int @map("timeliness_rating") @db.TinyInt professionalismRating Int @map("professionalism_rating") @db.TinyInt pricingRating Int @map("pricing_rating") @db.TinyInt overallRating Decimal @map("overall_rating") @db.Decimal(3, 2) platformRating Int @map("platform_rating") @db.TinyInt comments String? @map("comments") @db.VarChar(500) standardDescriptions Json? @map("standard_descriptions") reply String? @map("reply") @db.VarChar(500) repliedAt DateTime? @map("replied_at") editableUntil DateTime @map("editable_until") replyUntil DateTime? @map("reply_until") submittedAt DateTime @default(now()) @map("submitted_at") createdAt DateTime @default(now()) @map("created_at") updatedAt DateTime @updatedAt @map("updated_at") gig Gig @relation(fields: [gigId], references: [id], onDelete: Cascade) @@unique([gigId, ratedBy]) @@index([gigId]) @@index([ownerId, ownerRoleId]) @@index([providerId, providerRoleId]) @@map("cg_tbl_gig_ratings") }