From 93f99cae3508df58365423ec4c2b123dc8a7b2db Mon Sep 17 00:00:00 2001 From: pahmiudahgede Date: Mon, 13 Jan 2025 12:14:19 +0700 Subject: [PATCH] fix: fixing realtion struct request_items to request_pickups --- domain/request_pickup.go | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/domain/request_pickup.go b/domain/request_pickup.go index dde4872..6042eaa 100644 --- a/domain/request_pickup.go +++ b/domain/request_pickup.go @@ -2,10 +2,11 @@ package domain import "time" + type RequestPickup struct { ID string `gorm:"primaryKey;type:uuid;default:uuid_generate_v4()" json:"id"` UserID string `gorm:"type:uuid;not null" json:"userId"` - Request []RequestItem `gorm:"foreignKey:RequestPickupID" json:"request"` + Request []RequestItem `gorm:"foreignKey:RequestPickupID;constraint:OnUpdate:CASCADE,OnDelete:CASCADE;" json:"request"` RequestTime string `gorm:"type:text;not null" json:"requestTime"` UserAddressID string `gorm:"type:uuid;not null" json:"userAddressId"` UserAddress Address `gorm:"foreignKey:UserAddressID" json:"userAddress"` @@ -16,8 +17,8 @@ type RequestPickup struct { type RequestItem struct { ID string `gorm:"primaryKey;type:uuid;default:uuid_generate_v4()" json:"id"` - RequestPickupID string `gorm:"type:uuid;not null" json:"requestPickupId"` + RequestPickupID string `gorm:"type:uuid;not null;constraint:OnUpdate:CASCADE,OnDelete:CASCADE;" json:"requestPickupId"` TrashCategoryID string `gorm:"type:uuid;not null" json:"trashCategoryId"` TrashCategory TrashCategory `gorm:"foreignKey:TrashCategoryID" json:"trashCategory"` EstimatedAmount string `gorm:"type:text;not null" json:"estimatedAmount"` -} +} \ No newline at end of file