Skip to content
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

Charset or Collation are ignored during migration #5322

Closed
surikman opened this issue Mar 17, 2022 · 6 comments · Fixed by #5326
Closed

Charset or Collation are ignored during migration #5322

surikman opened this issue Mar 17, 2022 · 6 comments · Fixed by #5326

Comments

@surikman
Copy link

Bug Report

Q A
Version 3.3.*

Summary

After upgrade dbal from 2.x to 3.3.x doctrine migration generates down a lot of changes about COLLATE because in Comparatar charset & collation is null

$defaults = array_intersect_key($fromTable->getOptions(), [
'charset' => null,
'collation' => null,
]);

Current behaviour

We have a table:

CREATE TABLE IF NOT EXISTS `test` (`name` VARCHAR(255) NOT NULL) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB COMMENT = \'\';');

If I run migrations:diff:

  • up is empty
  • down contains changes for name column
ALTER TABLE test CHANGE name name VARCHAR(255) NOT NULL COLLATE `utf8mb4_unicode_ci`

How to reproduce

$connection = DriverManager::getConnection(['url' => 'mysql://root:root@127.0.0.1:3306/test?serverVersion=8.0']);
$connection->executeQuery('CREATE TABLE IF NOT EXISTS `test` (`name` VARCHAR(255) NOT NULL) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB COMMENT = \'\';');
$schemaManager = $connection->createSchemaManager();
$fromSchema = $schemaManager->createSchema();

$toSchema = new Schema([], [], $schemaManager->createSchemaConfig());
$toSchema->createTable('test')->addColumn(
    'name',
    Types::STRING,
    ['length' => 255, 'notnull' => true, 'platformOptions' => ['version' => false]]
);

$up = $schemaManager->createComparator()->compareSchemas($fromSchema, $toSchema);
$diffSql = $up->toSql($connection->getDatabasePlatform());
assert(count($diffSql) === 0);


$down = $schemaManager->createComparator()->compareSchemas($toSchema, $fromSchema);
$diffSql = $down->toSql($connection->getDatabasePlatform());
assert(count($diffSql) === 0);

Expected behaviour

Diff of UP & DOWN should be empty -> nothing to migrate

I created this issue from #5321 (comment)

@stefgodin
Copy link

stefgodin commented Mar 17, 2022

I have the same problem with v3.4.1 of doctrine/migrations.
The problem is resolved when forcing installation of v3.3.2 of doctrine/migrations.

@surikman
Copy link
Author

surikman commented Mar 17, 2022

@Stefmachine yes, You are right. I had doctrine/migrations:3.4.1 and I tried to install 3.3.2 and it works.

Ok It means, this is bug of doctrine/migrations or doctrine/dbal lib? 🤔

I think this issue comes from doctrine/migrations#1229

@stefgodin
Copy link

When I run the composer update command upon switching from 3.4.1 to 3.3.2 this shows up
image

Which seems to imply that only doctrine/migrations is updated and not doctrine/dbal.
Unless composer/package-versions-deprecated causes a problem but that is very unlikely.

@morozov
Copy link
Member

morozov commented Mar 20, 2022

@surikman please check the patch from #5326. As reported in the description, your issue is not reproducible with this patch.

@surikman
Copy link
Author

@surikman please check the patch from #5326. As reported in the description, your issue is not reproducible with this patch.

Thanks @morozov, now on branch 3.3.x-dev it works properly!

@github-actions
Copy link

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.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jul 20, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants