-
-
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
Diff on column with collation problem #2538
Comments
@mikeSimonson can you check this? |
I will look at it |
The issue can either be the schema object that is generated from the database connection, the schema that is generated from the ORM metadata or the diff between those 2. The SQL that I used to generate the table is slightly different from the bug report. It includes the Primary key directive because it's required by mysql5.7. CREATE TABLE `Contest` (
`id` int(11) NOT NULL PRIMARY KEY AUTO_INCREMENT
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci So far the differences that I can see between the 2 generated schema objects includes
The output of the diff is ALTER TABLE Contest CHANGE id id VARCHAR(32) NOT NULL I don't have the collation in the diff but it's the default on my setup. Applying the diff leads to those schemas differences
So the lenght difference has been fixed. Any rerun of the diff will now continue to output the same alter table as before. |
@Ocramius I would say that this bug is in two parts. The 2 differences that are detected are the collation and the auto_increment.
What do you think @Ocramius ? |
Is that PR #2551?
Can't do this, as we don't really know what the DB-side type may be doing. It may be an auto-fill integer mapped as string, for example. |
Yes but it's not right yet
Does that mean that I should verify that all types in DBAL/Types look for the autoincrement field property ? The stringType for instance doesn't look for it. |
No, it means that we can't assume whether a type supports auto-increment or not (also custom types) |
Cannot reproduce on $connection->executeStatement('DROP TABLE IF EXISTS `Contest`');
$connection->executeStatement('CREATE TABLE `Contest` (
`id` int(11) NOT NULL AUTO_INCREMENT PRIMARY KEY
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci');
$desiredTable = new Table('Contest', [
new Column('id', new StringType(), [
'length' => 32,
'notnull' => true,
'platformOptions' => [
'collate' => 'utf8_unicode_ci',
],
])
]);
$sm = $connection->createSchemaManager();
$actualTable = $sm->listTableDetails('Contest');
$comparator = new Comparator();
$diff = $comparator->diffTable($actualTable, $desiredTable);
$sm->alterTable($diff);
echo $connection->fetchNumeric('SHOW CREATE TABLE `Contest`')[1], PHP_EOL;
// CREATE TABLE `Contest` (
// `id` varchar(32) COLLATE utf8_unicode_ci NOT NULL
// ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8_unicode_ci
$actualTable = $sm->listTableDetails('Contest');
$diff = $comparator->diffTable($actualTable, $desiredTable);
var_dump($diff);
// false |
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. |
Copied from doctrine/migrations#495
Used versions:
Entity:
Current table:
Migration generated from diff:
So up() and down() do the same thing and if i execute this migration and rerun diff, it will generate the same migration again.
Any help appreciated.
The text was updated successfully, but these errors were encountered: