-
-
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
[2.10.0] Do not add CHARACTER SET for some column types #3714
Comments
cc @altertable |
Not really a BC break, but rather a regression. |
Our ci also broke this day with the same issue metioned above while executing: |
@williamdes, @ABartelt could you clarify where the column charset comes from? According to the logic introduced in #3418, dbal/lib/Doctrine/DBAL/Schema/MySqlSchemaManager.php Lines 195 to 197 in 73f38e7
The corresponding SQL is generated only if the charset is specified on the column. And I don't see code in the DBAL that would define any default charset. Can this issue be reproduced using only the DBAL APIs, without any wrapper libraries? |
When generating alter table SQL by Laravel migration, the column diff is calculated as Laravel Blueprint describes:
Now see the bugged migration, The Blueprint I think there are two ways to fix this, one is add extra checks in \Doctrine\DBAL\Schema\Table::changeColumn, another is modify Laravel migrate, add checks after changed attributes are set. I prefer the second one. |
Thank you @altertable for the explanation.
In order to make the proper decision, we need a scenario that reproduces the issue using only the DBAL API. |
Changing my json field also produces an error like that of the author. My code: public function up()
{
Schema::table('meta_tags', function (Blueprint $table) {
$table->json('meta_keywords')->change();
});
}
public function down()
{
Schema::table('meta_tags', function (Blueprint $table) {
$table->text('meta_keywords')->change();
});
} |
As mentioned above, we need this to be laid out in DBAL API only (no laravel) to identify the issue. |
Just one sample test:
This will cause failures:
|
@altertable you're providing the charset there by configuring the platform options. What happens if you remove that? |
@lcobucci The test will pass if remove the platform options. |
Experiencing the same issue when trying to change a column data type. Schema::table('users', function (Blueprint $table) {
$table->string('avatar');
});
Schema::table('users', function (Blueprint $table) {
$table->integer('avatar')->change();
}); |
@nicolasbuch IMHO the problem is that the tool you're using is sending wrong information to DBAL. That should be fixed by such tool. |
Same issue with us - Laravel 5.8 & mysql 5.7 and we have a migration from months ago changing a column type to JSON. On DBAL v2.9.2, it was working fine, but upgrading to 2.10, breaks at the loading of this migration (and during phpunit runs since the entire DB is reconstructed) |
Taking feedback from:
Closing here as |
I dont think this issue is invalid. I have Laravel migration from text to json. It works perfectly in 2.9.3 and 2.10.0 fails. This means that I am stuck with older dbal version.
|
Technically, not really. You can always use |
Folks, Laravel is using DBAL in the wrong way and relying on a bug. Once the bug got fixed this problem started to happen, hence it being invalid. I really understand your frustration but the message we're trying to convey here is that it's Laravel's responsibility to generate the correct object to be sent to DBAL. It seems like https://github.com/laravel/framework/blob/1bbe5528568555d597582fdbec73e31f8a818dbc/src/Illuminate/Database/Schema/Grammars/ChangeColumn.php#L125 is the culprit. So, please send a PR there to solve this once and for all 😁 |
I'm just going to happily link these two threads together, so both sides are informed and we can move further. Sorry I'm not going to contribute directly by merge request, I'm afraid this would result into a terrible mess. Cheers and thank you! |
I changed my version to 2.9.2 but still getting this issue while changing from string to unsignedBigInteger. Can someone please help or explain how can I fix this issue |
doctrine/dbal v2.10.0
Generated with doctrine:migrations:dump-schema. Dies with error when running.
|
I solved my errors in the migration files adding My new line now looks like this: |
I do confirm the issue still exists in Laravel 6.x and that is pretty confusing 😕 : When I was trying to refresh my migrations I got stuck with the following error:
which was caused by the following piece of code: public function down()
{
Schema::connection(env('DB_CONNECTION_FOO'))
->table('foo', function (Blueprint $table) {
$table->unsignedInteger('foo_type')->change();
});
} Previously I did not have any issues and I haven't made any changes to migrations since the last time they successfully run The workaround suggested by @stevenbuehner |
$table->json('column_name')->charset(null)->nullable()->change(); |
I'm in the same situation as @anususmi ( Guessing the only way to resolve this is to downgrade? |
Can I get a bump on this? Using it for work and we really don't wanna be on an outdated version of this library |
FYI this appears to have been resolved in laravel 6 and 7 |
still present in: error while trying to change column from text to blob workaround for me was to make a intermediary migration that runs above the alter and drop the column and recreate it for both fwd and reverse migration |
@strtz would you please report that to Laravel? |
laravel/framework#30539 added, just leaving info in both places in case someone is looking for workaround that do not involve raw statements |
By using |
I think dateTime is missing from that list. |
This still occurs in v2.13.x in doctrine migrations. public function up(Schema $schema) : void
{
$table = $schema->getTable(self::TABLE);
$column = $table->getColumn(self::COLUMN);
$column->setType(Type::getType(Types::JSON));
}
|
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. |
Bug Report
Summary
I use Laravel and when composer did the update from 2.9.2 to 2.10.0 our CI broke
Current behaviour
Generate:
How to reproduce
Using Laravel
Expected behaviour
Do not ADD
CHARACTER SET
Generate:
More
Introduced by : #3418 ?
The text was updated successfully, but these errors were encountered: