datasource db { provider = "mysql" } generator client { provider = "prisma-client" output = "../src/generated/prisma" moduleFormat = "cjs" } model User { id Int @id @default(autoincrement()) mobileNumber String @unique @db.Char(11) password String firstName String lastName String roleId Int role Role @relation("User_Role", fields: [roleId], references: [id], onUpdate: NoAction) @@map("Users") } model Role { id Int @id @default(autoincrement()) name String @db.VarChar(100) description String? @db.Text permissions Json? createdAt DateTime @default(now()) @db.Timestamp(0) updatedAt DateTime @updatedAt @db.Timestamp(0) deletedAt DateTime? @db.Timestamp(0) users User[] @relation("User_Role") @@map("Roles") } model Product { id Int @id @default(autoincrement()) name String @db.VarChar(255) description String? @db.Text sku String? @unique(map: "products_sku_unique") @db.VarChar(100) barcode String? @unique(map: "products_barcode_unique") @db.VarChar(100) imageUrl String? @db.VarChar(255) attachmentId BigInt? @db.UnsignedBigInt unit String @db.VarChar(10) discount Decimal @default(0.00) @db.Decimal(10, 2) quantity Decimal @default(0.00) @db.Decimal(10, 2) alertQuantity Decimal @default(5.00) @db.Decimal(10, 2) isActive Boolean @default(true) isFeatured Boolean @default(false) createdAt DateTime? @db.Timestamp(0) updatedAt DateTime? @db.Timestamp(0) deletedAt DateTime? @db.Timestamp(0) productInfo ProductInfo @relation("Product_ProductInfo", fields: [productInfoId], references: [id], onUpdate: NoAction) productInfoId Int // is_stock_managed Boolean @default(true) // created_by Int? // collection_product collection_product[] // product_batches product_batches[] // product_stocks product_stocks[] // attachments attachments? @relation(fields: [attachment_id], references: [id], onUpdate: NoAction, map: "products_attachment_id_foreign") // purchase_items purchase_items[] // sale_items sale_items[] // @@index([attachment_id], map: "products_attachment_id_foreign") @@map("Products") } model ProductInfo { id Int @id @default(autoincrement()) name String @db.VarChar(255) description String? @db.Text productType String? @default("simple") @db.VarChar(50) metaData Json? createdAt DateTime @default(now()) @db.Timestamp(0) updatedAt DateTime @updatedAt @db.Timestamp(0) deletedAt DateTime? @db.Timestamp(0) products Product[] @relation("Product_ProductInfo") brand ProductBrand? @relation("ProductInfo_Brand", fields: [brandId], references: [id], onUpdate: NoAction) brandId Int? category ProductCategory? @relation("ProductInfo_Category", fields: [categoryId], references: [id], onUpdate: NoAction) categoryId Int? supplier Supplier @relation("ProductInfo_Supplier", fields: [supplierId], references: [id], onUpdate: NoAction) supplierId Int @@map("Product_info") } model ProductBrand { id Int @id @default(autoincrement()) name String @db.VarChar(100) description String? @db.Text imageUrl String? @db.VarChar(255) createdAt DateTime @default(now()) @db.Timestamp(0) updatedAt DateTime @updatedAt @db.Timestamp(0) deletedAt DateTime? @db.Timestamp(0) productInfo ProductInfo[] @relation("ProductInfo_Brand") @@map("Product_brands") } model ProductCategory { id Int @id @default(autoincrement()) name String @db.VarChar(100) description String? @db.Text imageUrl String? @db.VarChar(255) createdAt DateTime @default(now()) @db.Timestamp(0) updatedAt DateTime @updatedAt @db.Timestamp(0) deletedAt DateTime? @db.Timestamp(0) productInfo ProductInfo[] @relation("ProductInfo_Category") @@map("Product_categories") } model Supplier { id Int @id @default(autoincrement()) firstName String @db.VarChar(255) lastName String @db.VarChar(255) email String? @db.VarChar(255) mobileNumber String @unique @db.Char(11) address String? @db.Text city String? @db.VarChar(100) state String? @db.VarChar(100) country String? @db.VarChar(100) isActive Boolean @default(true) createdAt DateTime? @db.Timestamp(0) updatedAt DateTime? @db.Timestamp(0) deletedAt DateTime? @db.Timestamp(0) productInfo ProductInfo[] @relation("ProductInfo_Supplier") @@map("Suppliers") } model Customer { id Int @id @default(autoincrement()) firstName String @db.VarChar(255) lastName String @db.VarChar(255) email String? @db.VarChar(255) mobileNumber String @unique @db.Char(11) address String? @db.Text city String? @db.VarChar(100) state String? @db.VarChar(100) country String? @db.VarChar(100) isActive Boolean @default(true) createdAt DateTime? @db.Timestamp(0) updatedAt DateTime? @db.Timestamp(0) deletedAt DateTime? @db.Timestamp(0) @@map("Customers") } model Inventory { id Int @id @default(autoincrement()) name String @db.VarChar(255) location String? @db.VarChar(255) isActive Boolean @default(true) createdAt DateTime @db.Timestamp(0) updatedAt DateTime @db.Timestamp(0) @@map("Inventories") } model Store { id Int @id @default(autoincrement()) name String @db.VarChar(255) location String? @db.VarChar(255) isActive Boolean @default(true) createdAt DateTime @db.Timestamp(0) updatedAt DateTime @db.Timestamp(0) @@map("Stores") }