feat: Enhance User and Farmer models with createdBy and updatedBy fields for better tracking

This commit is contained in:
Abdul Kholik Sobary 2025-07-07 13:26:40 +07:00
parent 68c62313e4
commit 99778f5cb7
1 changed files with 10 additions and 5 deletions

View File

@ -279,10 +279,12 @@ model User {
updatedAt DateTime @updatedAt
// Relations
farmer Farmer?
buyer Buyer?
administrator Administrator?
notifications NotificationRecipient[]
farmer Farmer?
buyer Buyer?
administrator Administrator?
notifications NotificationRecipient[]
createdFarmers Farmer[] @relation("FarmerCreatedBy")
updatedFarmers Farmer[] @relation("FarmerUpdatedBy")
@@map("users")
}
@ -341,7 +343,6 @@ model Farmer {
landOwnership LandOwnership? // Kepemilikan lahan tempat tinggal
primaryCrop String?
farmingMethods String[] // organic, conventional, etc.
hasSmartphone Boolean? @default(true)
internetAccess Boolean? @default(true)
// Emergency contact
@ -355,9 +356,13 @@ model Farmer {
joinedAt DateTime @default(now())
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
createdBy String? // User ID who created this farmer record
updatedBy String? // User ID who last updated this farmer record
// Relations
user User @relation(fields: [userId], references: [id], onDelete: Cascade)
creator User? @relation("FarmerCreatedBy", fields: [createdBy], references: [id])
updater User? @relation("FarmerUpdatedBy", fields: [updatedBy], references: [id])
identities FarmerIdentity[]
bankAccounts FarmerBankAccount[]
vehicles FarmerVehicle[]