code: func (r *GormWorkItemTypeRepository) CreateFromModel(ctx context.Context, model WorkItemType) (*WorkItemType, error) {
  	defer goa.MeasureSince([]string{"goa", "db", "workitemtype", "create"}, time.Now())
  
  	if model.ID == uuid.Nil {
  		model.ID = uuid.NewV4()
  	}
  
  	allFields := map[string]FieldDefinition{}
  	path := LtreeSafeID(model.ID)
  	if model.Extends != uuid.Nil {
  		extendedType := WorkItemType{}
  		db := r.db.Model(&extendedType).Where("id=?", model.Extends).First(&extendedType)
  		if db.RecordNotFound() {
  			return nil, errors.NewBadParameterError("extendedTypeID", model.Extends)
  		}
  		if err := db.Error; err != nil {
  			return nil, errors.NewInternalError(ctx, err)
  		}
  		// copy fields from extended type
  		for key, value := range extendedType.Fields {
  			allFields[key] = value
  		}
  		path = extendedType.Path + pathSep + path
  	}
  	// now process new fields, checking whether they are already there.
  	for field, definition := range model.Fields {
  		existing, exists := allFields[field]
  		if exists && !compatibleFields(existing, definition) {
  			return nil, errs.Errorf("incompatible change for field %s", field)
  		}
  		allFields[field] = definition
  	}
  
  	model.Version = 0
  	model.Path = path
  	model.Fields = allFields
  
  	db := r.db.Create(&model)
  	if db.Error != nil {
  		return nil, errors.NewInternalError(ctx, db.Error)
  	}
  	return &model, nil
  }
docs: // CreateFromModel creates a new work item type in the repository based on the
  // given model of it.