-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Column altering in migration from TEXT to LONGTEXT may not apply. #2566
Comments
@janokary what RDBMs does this apply to? Maybe this is missing schema introspection? |
It is allways mysql
or
or
|
@janokary I need more information. What is the Doctrine DBAL type before and what should it be after? Also |
Hi all, I'm facing same issue, using Laravel 5.4, doctrine/dbal v2.5.12, php 5.6.30, mysql Ver 14.14 Distrib 5.6.33. before: The column type should be |
@ariews can this be reproduced with DBAL-only? |
For this issue, doctrine#2566
Any news on getting this integrated? |
@frandieguez this needs a test case first. |
@Ocramius I can see that the solution presented at https://github.com/Cheezykins/dbal/commit/c119353f7832cd4da2003b0ce388f7727e3fcfa9 contains a test case. Does this solution is "good enought"? I'm quite interested on getting this merged, even if I can help in some way. |
Can't find a PR for that: can you open or dig up one? |
@Ocramius here's your PR. |
I came across this issue trying to change a column in a Laravel application from text to longtext. I traced the migration and the issue was that the change was ignored since $changedProperties was empty although the _length was different (65535 on $table1 vs 16777216 on $table2) .
and the change migration like this:
|
I have added some comments on my PR. There's an issue with a failing test which i feel is not well defined. |
Any movement on this? Currently experiencing this problem, and google brought me to this github issue created over 2 years ago... ! |
Some helpful fellow has suggested this workaround, for those who come after me: laravel/framework#21847 (comment) tldr; change to string column with length > 16777216, since it exceeds varchar max length the column gets converted to longtext. Hacky, but it works. |
I found another workaround. Just change the column comment, for example:
Works perfectly on Ubuntu 18.04, PHP 7.2, MySQL 8, Laravel 5.8 |
I am using the same method to solve the problem. That works. |
Ran across this after trying to diagnose the problem for the last hour. Both hacks work. Fixing $table->longText()->change() would be even better. |
this works as well on ubuntu 16.04, php 7.0 and mariadb 10.2.8, Laravel 5.4 |
As of today.. this bug is still in laravel..
As of today.. this bug is still in laravel and this is the fix.. |
As of today, when changing between text types (text, mediumText, or longText), this is still the fix. |
This bug will be covered by the Additionally, $column = new Column('myColumn', new TextType(), [
'length' => 2**15, // TEXT
]);
$desiredTable = new Table('test', [$column]);
$sm = $connection->createSchemaManager();
$sm->dropAndCreateTable($desiredTable);
echo $connection->fetchNumeric('SHOW CREATE TABLE test')[1], PHP_EOL;
// CREATE TABLE `test` (
// `myColumn` text COLLATE utf8_unicode_ci NOT NULL
// ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8_unicode_ci
$column->setLength(2**24); // LONGTEXT
$actualTable = $sm->listTableDetails('test');
$comparator = $sm->createComparator();
$diff = $comparator->diffTable($actualTable, $desiredTable);
$sm->alterTable($diff);
echo $connection->fetchNumeric('SHOW CREATE TABLE test')[1], PHP_EOL;
// CREATE TABLE `test` (
// `myColumn` longtext COLLATE utf8_unicode_ci NOT NULL
// ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8_unicode_ci |
This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs. |
Based on this
laravel/framework#12363
and my experience here
https://laracasts.com/discuss/channels/laravel/alter-table-change-field-to-longtext
I think there is a problem when migrating a table column from TEXT to LONG TEXT
The text was updated successfully, but these errors were encountered: