Details
-
Type:
Bug
-
Status:
Open
-
Priority:
Minor
-
Resolution: Unresolved
-
Affects Version/s: None
-
Fix Version/s: None
-
Component/s: None
-
Labels:None
-
Environment:Linux, Symfony 1.4, Doctrine 1.2
Description
I am using a database designed using schema.yml with a MySql Server.
When I add a field of type text the generated code for the migrations (using diff) is as follows:
$this->addColumn('<tableName>', '<fieldName>, 'text', '', array(
'notnull' => '',
));
Which produces a MySQL error like this:
SQLSTATE[42000]: Syntax error or access violation: 1064 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 <fieldName> text()"
The solution I found was to manipulate manually the generated class to use an addColumn like this:
$this->addColumn('<tableName>', '<fieldName>, 'text', null, array(
'notnull' => '',
));
Which would generate an SQL statement like this:
ALTER TABLE <tableName> ADD <fieldName> text
Which works fine with MySQL, don't know about other RDBMS
My understanding is that you need to put a size to the text so it will choose between tinytext, text, mediumtext, bigtext, so instead of
$this->addColumn('<tableName>', '<fieldName>, 'text', '', array(
'notnull' => '',
));
use
$this->addColumn('<tableName>', '<fieldName>, 'text', '<somenumber>', array(
'notnull' => '',
));