package database import ( "time" "github.com/google/uuid" "gorm.io/gorm" ) // BaseModel contains common fields for all models // This replaces gorm.Model but uses UUID instead of uint for ID type BaseModel struct { ID string `gorm:"type:uuid;primary_key" json:"id"` CreatedAt time.Time `json:"createdAt"` UpdatedAt time.Time `json:"updatedAt"` DeletedAt gorm.DeletedAt `gorm:"index" json:"deletedAt,omitzero"` } // BeforeCreate hook to set UUID before creating a record. func (b *BaseModel) BeforeCreate(_ *gorm.DB) error { if b.ID == "" { b.ID = uuid.New().String() } return nil }