migrations-generator icon indicating copy to clipboard operation
migrations-generator copied to clipboard

Column LONGTEXT is generated as TEXT

Open brseixas opened this issue 8 years ago • 5 comments

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.

brseixas avatar Dec 05 '16 16:12 brseixas

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.

Xethron avatar Feb 23 '17 11:02 Xethron

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

brseixas avatar Feb 23 '17 13:02 brseixas

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

omarjebari avatar Jan 24 '18 22:01 omarjebari

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 avatar Sep 18 '18 16:09 rygilles

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

rygilles avatar Sep 19 '18 09:09 rygilles