[Doctrine\DBAL\Exception\DriverException]... SQLSTATE[42000] error when generating my databases tables with Doctrine
<p>I just finished creating my entities in Symfony3 using Doctrine. Now, I want to generate table in order to manage it.
For that reason, I firstly ran this command line to create my database :</p>

<pre><code> php bin/console doctrine:database:create
</code></pre>

<p>And it worked great ! Now I want to generate the tables, I just ran this command line :</p>

<pre><code> php bin/console doctrine:schema:update --force
</code></pre>

<p>and I got this error :</p>

<pre><code>[Doctrine\DBAL\Exception\DriverException]                                                                                                                              
An exception occurred while executing 'CREATE TABLE contribution (id INT 
AUTO_INCREMENT NOT NULL, question_id INT DEFAULT NULL, libelle TEXT NOT  NULL, 
type VARCHAR(2  
55) NOT NULL, nombre_like INT NOT NULL, date_publication DATETIME NOT NULL,   report TINYINT(1) NOT NULL, UNIQUE INDEX UNIQ_EA351E15A4D60759 (libelle), INDEX IDX_EA351  
E151E27F6BF (question_id), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci ENGINE = InnoDB':                                                       
SQLSTATE[42000]: Syntax error or access violation: 1170 BLOB/TEXT column 'libelle' used in key specification without a key length



[Doctrine\DBAL\Driver\PDOException]                                                                                                
SQLSTATE[42000]: Syntax error or access violation: 1170 BLOB/TEXT column  'libelle' used in key specification without a key length

[PDOException]                                                                                                                     
SQLSTATE[42000]: Syntax error or access violation: 1170 BLOB/TEXT column 'libelle' used in key specification without a key length
</code></pre>

<p>Here is my Commentaire table entity :</p>

<pre><code>  class Commentaire
{
/**
 * @var int
 *
 * @ORM\Column(name="id", type="integer")
 * @ORM\Id
 * @ORM\GeneratedValue(strategy="AUTO")
 */
protected $id;
/**
 * @var string
 * @ORM\Column(name="libelle", type="text", nullable=true)
 */
private $libelle;

/**
 * @var int
 *
 * @ORM\Column(name="depth", type="integer")
 */
protected $depth;

/**
 * @var int
 *
 * @ORM\Column(name="parent_id", type="integer")
 */
protected $parent_id;

/**
 * @var int
 *
 * @ORM\Column(name="nombre_like", type="integer")
 */
protected $nombreLike;

/**
 * @var \DateTime
 *
 * @ORM\Column(name="date_publication", type="datetimetz", nullable=false)
 */
protected $datePublication;

/**
 * @var bool
 *
 * @ORM\Column(name="report", type="boolean")
 */
protected $report;

/**
 * @ORM\ManyToOne(targetEntity="Contribution", inversedBy="commentaires")
 * @var Contribution
 */
protected $contribution;

/**
 * @ManyToMany(targetEntity="Enseignant", mappedBy="commentaires")
 */
protected $enseignants;

/**
 * @ManyToMany(targetEntity="Etudiant", mappedBy="commentaires")
 */
protected $etudiants;


/**
 * Get id
 *
 * @return int
 */
public function getId()
{
    return $this-&gt;id;
}

/**
 * Set libelle
 *
 * @param string $libelle
 *
 * @return Commentaire
 */
public function setLibelle($libelle)
{
    $this-&gt;libelle = $libelle;

    return $this;
}

/**
 * Get libelle
 *
 * @return string
 */
public function getLibelle()
{
    return $this-&gt;libelle;
}

/**
 * Set depth
 *
 * @param integer $depth
 *
 * @return Commentaire
 */
public function setDepth($depth)
{
    $this-&gt;depth = $depth;

    return $this;
}

/**
 * Get depth
 *
 * @return int
 */
public function getDepth()
{
    return $this-&gt;depth;
}

/**
 * Set parentId
 *
 * @param integer $parentId
 *
 * @return Commentaire
 */
public function setParentId($parentId)
{
    $this-&gt;parent_id = $parentId;

    return $this;
}

/**
 * Get parentId
 *
 * @return int
 */
public function getParentId()
{
    return $this-&gt;parent_id;
}

/**
 * Set nombreLike
 *
 * @param integer $nombreLike
 *
 * @return Commentaire
 */
public function setNombreLike($nombreLike)
{
    $this-&gt;nombreLike = $nombreLike;

    return $this;
}

/**
 * Get nombreLike
 *
 * @return int
 */
public function getNombreLike()
{
    return $this-&gt;nombreLike;
}

/**
 * Set datePublication
 *
 * @param \DateTime $datePublication
 *
 * @return Commentaire
 */
public function setDatePublication($datePublication)
{
    $this-&gt;datePublication = $datePublication;

    return $this;
}

/**
 * Get datePublication
 *
 * @return \DateTime
 */
public function getDatePublication()
{
    return $this-&gt;datePublication;
}

/**
 * Set report
 *
 * @param boolean $report
 *
 * @return Commentaire
 */
public function setReport($report)
{
    $this-&gt;report = $report;

    return $this;
}

/**
 * Get report
 *
 * @return bool
 */
public function getReport()
{
    return $this-&gt;report;
}
/**
 * Constructor
 */
public function __construct()
{
    $this-&gt;enseignants = new \Doctrine\Common\Collections\ArrayCollection();
    $this-&gt;etudiants = new \Doctrine\Common\Collections\ArrayCollection();
}

/**
 * Set contribution
 *
 * @param \AppBundle\Entity\Contribution $contribution
 *
 * @return Commentaire
 */
public function setContribution(\AppBundle\Entity\Contribution $contribution = null)
{
    $this-&gt;contribution = $contribution;

    return $this;
}

/**
 * Get contribution
 *
 * @return \AppBundle\Entity\Contribution
 */
public function getContribution()
{
    return $this-&gt;contribution;
}

/**
 * Add enseignant
 *
 * @param \AppBundle\Entity\Enseignant $enseignant
 *
 * @return Commentaire
 */
public function addEnseignant(\AppBundle\Entity\Enseignant $enseignant)
{
    $this-&gt;enseignants[] = $enseignant;

    return $this;
}

/**
 * Remove enseignant
 *
 * @param \AppBundle\Entity\Enseignant $enseignant
 */
public function removeEnseignant(\AppBundle\Entity\Enseignant $enseignant)
{
    $this-&gt;enseignants-&gt;removeElement($enseignant);
}

/**
 * Get enseignants
 *
 * @return \Doctrine\Common\Collections\Collection
 */
public function getEnseignants()
{
    return $this-&gt;enseignants;
}

/**
 * Add etudiant
 *
 * @param \AppBundle\Entity\Etudiant $etudiant
 *
 * @return Commentaire
 */
public function addEtudiant(\AppBundle\Entity\Etudiant $etudiant)
{
    $this-&gt;etudiants[] = $etudiant;

    return $this;
}

/**
 * Remove etudiant
 *
 * @param \AppBundle\Entity\Etudiant $etudiant
 */
public function removeEtudiant(\AppBundle\Entity\Etudiant $etudiant)
{
    $this-&gt;etudiants-&gt;removeElement($etudiant);
}

/**
 * Get etudiants
 *
 * @return \Doctrine\Common\Collections\Collection
 */
public function getEtudiants()
{
    return $this-&gt;etudiants;
}}
</code></pre>

<p>libelle seems correct, but I don't know why I got that error. I even changed the type of libelle to string, but the error remains. I think is because doctrine adds index on libelle column (see the query) which is prohibited because the type is TEXT. Any idea how to remove that ? Please help !</p>