package entity import ( "narasi-ahli-be/app/database/entity/users" "time" ) type ChatSessions struct { ID uint `json:"id" gorm:"primaryKey;type:int4;autoIncrement"` Name *string `json:"name" gorm:"type:varchar(255)"` // null for personal chat, filled for group chat Type string `json:"type" gorm:"type:varchar(20);not null;default:'personal'"` // 'personal' or 'group' CreatedBy uint `json:"created_by" gorm:"type:int4;not null;index"` CreatedAt time.Time `json:"created_at" gorm:"default:now()"` UpdatedAt time.Time `json:"updated_at" gorm:"default:now()"` // Relationships Creator *users.Users `json:"creator" gorm:"foreignKey:CreatedBy;references:ID"` Participants []*ChatParticipants `json:"participants" gorm:"foreignKey:ChatSessionID;references:ID"` Messages []*ChatMessages `json:"messages" gorm:"foreignKey:ChatSessionID;references:ID"` }