Error with Doctrine – Symfony migrate and text field

first read this for general help on understanding

If you have in your migration file something like :

        $this->addColumn('< tablename >', '< columnname >', 'text', '', array(
             'notnull' => '',

Then, if you get the error,

You have an error in your SQL syntax; check the manual that corresponds to
your MySQL server version for the right syntax to use near '()' at line 1.
Failing Query: "ALTER TABLE < tablename > ADD < columnname > text()".

Instead use the type string with no length
You will end up with :

        $this->addColumn('< tablename >', '< columnname >', 'string', '', array(
             'notnull' => '',

any other number than 0 will result in the field being made into either tinytext, text, mediumtext or bigtext depending on the number (see data-type for mysql)

update :
actually the best thing to do is to make sure to use string in your schema.yml instead of text


Leave a Reply