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 ProductVariant { id Int @id @default(autoincrement()) name String @db.VarChar(255) basePrice Decimal @db.Decimal(10, 2) salePrice Decimal @db.Decimal(10, 2) description String? @db.Text barcode String? @unique(map: "products_barcode_unique") @db.VarChar(100) imageUrl String? @db.VarChar(255) unit String? @db.VarChar(10) 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) product Product @relation("Product_Variant", fields: [productId], references: [id], onUpdate: NoAction) productId 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[] @@map("Product_Variants") } model Product { id Int @id @default(autoincrement()) name String @db.VarChar(255) barcode String? @unique(map: "products_barcode_unique") @db.VarChar(100) sku String? @unique(map: "products_sku_unique") @db.VarChar(100) description String? @db.Text // productType String? @default("simple") @db.VarChar(50) createdAt DateTime @default(now()) @db.Timestamp(0) updatedAt DateTime @updatedAt @db.Timestamp(0) deletedAt DateTime? @db.Timestamp(0) variants ProductVariant[] @relation("Product_Variant") brand ProductBrand? @relation("Product_Brand", fields: [brandId], references: [id], onUpdate: NoAction) brandId Int? category ProductCategory? @relation("Product_Category", fields: [categoryId], references: [id], onUpdate: NoAction) categoryId Int? @@map("Products") } 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) products Product[] @relation("Product_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) products Product[] @relation("Product_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) @@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") }