feat(entities): Add MCrossReferenceEntity and MVendorEntity with relationships, and update MProductEntity to include cross references
This commit is contained in:
parent
371c2f8e16
commit
d1abcacacf
|
|
@ -0,0 +1,20 @@
|
|||
package entities
|
||||
|
||||
import (
|
||||
"github.com/google/uuid"
|
||||
)
|
||||
|
||||
type MCrossReferenceEntity struct {
|
||||
ID uuid.UUID `gorm:"type:uuid;primary_key;default:uuid_generate_v4()"`
|
||||
ProductID uuid.UUID `gorm:"type:uuid;not null;index;"`
|
||||
VendorID uuid.UUID `gorm:"type:uuid;not null;index;"`
|
||||
|
||||
Product MProductEntity `gorm:"foreignKey:ProductID;references:ID"`
|
||||
Vendor MVendorEntity `gorm:"foreignKey:VendorID;references:ID"`
|
||||
|
||||
FullAuditTrail
|
||||
}
|
||||
|
||||
func (MCrossReferenceEntity) TableName() string {
|
||||
return "m_cross_references"
|
||||
}
|
||||
|
|
@ -40,16 +40,17 @@ type MProductEntity struct {
|
|||
LeadTimeUomID uuid.UUID `gorm:"type:uuid;index" json:"lead_time_uom_id"`
|
||||
UomToUomID uuid.UUID `gorm:"type:uuid;index" json:"uom_to_uom_id"`
|
||||
|
||||
Client M_Client `gorm:"foreignKey:ClientID;references:ID;constraint:OnUpdate:CASCADE,OnDelete:SET NULL;"`
|
||||
Category MCategoryEntity `gorm:"foreignKey:CategoryID;references:ID"`
|
||||
Uom MUomEntity `gorm:"foreignKey:UomID;references:ID"`
|
||||
DimUom MUomEntity `gorm:"foreignKey:DimUomID;references:ID"`
|
||||
WeightUom MUomEntity `gorm:"foreignKey:WeightUomID;references:ID"`
|
||||
VolumeUom MUomEntity `gorm:"foreignKey:VolumeUomID;references:ID"`
|
||||
MinStockUom MUomEntity `gorm:"foreignKey:MinStockUomID;references:ID"`
|
||||
MaxStockUom MUomEntity `gorm:"foreignKey:MaxStockUomID;references:ID"`
|
||||
LeadTimeUom MUomEntity `gorm:"foreignKey:LeadTimeUomID;references:ID"`
|
||||
UomToUom MUomEntity `gorm:"foreignKey:UomToUomID;references:ID"`
|
||||
Client M_Client `gorm:"foreignKey:ClientID;references:ID;constraint:OnUpdate:CASCADE,OnDelete:SET NULL;"`
|
||||
Category MCategoryEntity `gorm:"foreignKey:CategoryID;references:ID"`
|
||||
Uom MUomEntity `gorm:"foreignKey:UomID;references:ID"`
|
||||
DimUom MUomEntity `gorm:"foreignKey:DimUomID;references:ID"`
|
||||
WeightUom MUomEntity `gorm:"foreignKey:WeightUomID;references:ID"`
|
||||
VolumeUom MUomEntity `gorm:"foreignKey:VolumeUomID;references:ID"`
|
||||
MinStockUom MUomEntity `gorm:"foreignKey:MinStockUomID;references:ID"`
|
||||
MaxStockUom MUomEntity `gorm:"foreignKey:MaxStockUomID;references:ID"`
|
||||
LeadTimeUom MUomEntity `gorm:"foreignKey:LeadTimeUomID;references:ID"`
|
||||
UomToUom MUomEntity `gorm:"foreignKey:UomToUomID;references:ID"`
|
||||
CrossReferences []MCrossReferenceEntity `gorm:"foreignKey:ProductID;references:ID"`
|
||||
|
||||
FullAuditTrail
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,23 @@
|
|||
package entities
|
||||
|
||||
import "github.com/google/uuid"
|
||||
|
||||
type MVendorEntity struct {
|
||||
ID uuid.UUID `gorm:"primaryKey;type:uuid;default:uuid_generate_v4()" json:"id"`
|
||||
SearchKey string `gorm:"type:varchar(255);index;"`
|
||||
Name string `gorm:"type:varchar(100);not null;"`
|
||||
Address string `gorm:"type:text"`
|
||||
ContactPerson string `gorm:"type:varchar(100);"`
|
||||
IsActive bool `gorm:"type:boolean;default:true"`
|
||||
|
||||
ClientID uuid.UUID `gorm:"type:uuid;index;"`
|
||||
|
||||
Client M_Client `gorm:"foreignKey:ClientID;references:ID"`
|
||||
CrossReferences []MCrossReferenceEntity `gorm:"foreignKey:VendorID;references:ID"`
|
||||
|
||||
FullAuditTrail
|
||||
}
|
||||
|
||||
func (MVendorEntity) TableName() string {
|
||||
return "m_vendors"
|
||||
}
|
||||
|
|
@ -23,6 +23,8 @@ func Migrate(db *gorm.DB) error {
|
|||
&entities.MProductEntity{},
|
||||
&entities.MCategoryEntity{},
|
||||
&entities.MUomEntity{},
|
||||
&entities.MVendorEntity{},
|
||||
&entities.MCrossReferenceEntity{},
|
||||
); err != nil {
|
||||
return err
|
||||
}
|
||||
|
|
@ -46,9 +48,11 @@ func MigrateFresh(db *gorm.DB) error {
|
|||
// &entities.M_MaintenanceGroup{},
|
||||
// &entities.M_MaintenanceGroupRole{},
|
||||
// &entities.M_MaintenanceGroupRoleUser{},
|
||||
&entities.MCategoryEntity{},
|
||||
// &entities.MCategoryEntity{},
|
||||
&entities.MProductEntity{},
|
||||
&entities.MUomEntity{},
|
||||
// &entities.MUomEntity{},
|
||||
&entities.MVendorEntity{},
|
||||
&entities.MCrossReferenceEntity{},
|
||||
); err != nil {
|
||||
return err
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue