Xethron / migrations-generator

Laravel Migrations Generator: Automatically generate your migrations from an existing database schema.
MIT License
3.33k stars 588 forks source link

Column LONGTEXT is generated as TEXT #105

Open brseixas opened 7 years ago

brseixas commented 7 years ago

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.

Xethron commented 7 years ago

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.

brseixas commented 7 years ago

Thanks for the feedback =) In my case I am using Eloquent (Laravel 5.2).

omarjebari commented 6 years ago

This also occurs with Laravel version 5.5 as well. It's not an easy bug to identify either.

rygilles commented 5 years ago

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);
                }
            }
rygilles commented 5 years ago

https://github.com/doctrine/dbal/issues/3292