migrations-generator
migrations-generator copied to clipboard
Column LONGTEXT is generated as TEXT
Hey, first of all thanks for the great plugin =)
I noticed that if the column is LONGTEXT, the generated migration file does not translate to $this->longText('...') but $this->text('...'). So we end up with a TEXT column instead of a LONGTEXT.
Hello @brseixas, thank you for opening this issue. Will have to look into whats causing this. I believe it might be Doctrine that doesn't differentiate between the two.
Thanks for the feedback =) In my case I am using Eloquent (Laravel 5.2).
This also occurs with Laravel version 5.5 as well. It's not an easy bug to identify either.
Facing the same issue and noticed that is the same with "mediumtext" Checking the length here (check code below) work for mediumtext but longtext give length=0 So it's a DBAL related bug I think.
https://github.com/Xethron/migrations-generator/blob/a05bd7319ed808fcc3125212e37d30ccbe0d2b8b/src/Xethron/MigrationsGenerator/Generators/FieldGenerator.php#L87-L159
My workaround for mediumtext type (L140-L146) :
} else {
// Probably not a number (string/char)
if ($type === 'string' && $column->getFixed()) {
$type = 'char';
}
if ($length == 16777215) {
$type = 'mediumText';
$length = null;
} else {
$args = $this->getLength($length);
}
}
https://github.com/doctrine/dbal/issues/3292