-
Notifications
You must be signed in to change notification settings - Fork 11.1k
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
MYSQL 8 Migrating text to alternative text type does not change column #46492
Comments
Here's a repo that reproduces the error: https://github.com/liamh101/laravel-column-bug It's around |
See #45487 |
Thanks for the response. I'll remove dbal from our codebase and check if it doesn't affect anything else. However, I think this problem should be fixed. On closer inspection, what I believe is happening is the current type, and the new type is checked using an enum in the dbal library. However, any text column generates the same enum. Meaning the migration thinks nothing has changed. If there's no movement by the end of today, I'll spend some time and get a fix for this over the weekend. Edit: Some people may find dbal still included in their project as it's a third-party requirement of |
@hafezdivandari what are your thoughts here? |
@driesvints the issue seems to be behavioral change on I've added a test for changing an @liamh101 you have 2 options:
|
@hafezdivandari thank you! @liamh101 does any of that work for you? |
Removing the DBAL won't work as some child dependencies may require it (like
This bug will significantly affect multi-tenanted applications, where migrations are often run for new clients. This could potentially go under the radar and break their systems without realising it. |
@hafezdivandari @driesvints spoke too soon. It does fix the text type bug. However, it has introduced another bug in which a nullable column was not set or reverted. I need to investigate exactly what's happening. Would you like me to append this issue or create a new one? |
@liamh101 Would you please check the L10 documentation on modifying column (it's different than L9), or check the related PR #45487 for more details on the topic.
|
@hafezdivandari Ah right, apologies, can't migrate to the new schema operations then. As this would break in multiple places without rewriting a lot of my migrations. Both of those solutions first provided won't work for the time being. |
@liamh101 no problem, as I said you may call that function only on your last migration only: public function up(): void
{
Schema::useNativeSchemaOperationsIfPossible()
Schema::table('tableName', static function (Blueprint $table) {
$table->mediumText('col1')->nullable()->change();
});
Schema::useNativeSchemaOperationsIfPossible(false);
} Unfortunately this bug on |
I think, from reading up here, there's not much we can do ourselves, sorry. Feel free to either switch to non-DBAL and modify your code as instructed by @hafezdivandari above or open an issue on the DBAL repo. Thanks |
I've also recently run into this problem with a Doing what @hafezdivandari suggests Schema::useNativeSchemaOperationsIfPossible()
// migrations here
Schema::useNativeSchemaOperationsIfPossible(false); Solve the problem. thanks for that |
doctrine/dbal
Version: 3.6.1Description:
The column type change will not be made during a text column's migration to medium or long text. Keeping the column as a text type.
Stepping through the process,
Illuminate\Database\Schema\Grammars\ChangeColumn
class line 44$tableDiff->isEmpty()
returnstrue
.Not sure what other columns this affects. This bug occurred during my migration process to Laravel 9 to 10.
Steps To Reproduce:
database.php
as follows (based on MySQL8 docker image):text
type.The text was updated successfully, but these errors were encountered: