doctrine / migrations

Doctrine Database Migrations Library
https://www.doctrine-project.org/projects/migrations.html
MIT License
4.65k stars 386 forks source link

Migration with a binary type #1376

Closed lecneri closed 8 months ago

lecneri commented 8 months ago

I'm trying to create a migration with uuid as follow

$table = $schema->createTable('t');
$table->addColumn('id', Types::BINARY, [
    'comment' => '(DC2Type:uuid)',
    'notnull' => true,
    'length' => 16,
]);

What happens is Types::BINARY returns string 'binary', which is mapped to varbinary and after my migration command runs, it executes an extra migration modifying the column to binary type.

This last modification messes with any migration that has foreign key added, because it can't change type anymore.

To notice this extra command running, I used doctrine:migrations:migrate -vv

derrabus commented 8 months ago

Does it work if you omit the comment setting?

lecneri commented 8 months ago

Hello @derrabus thank for your reply Today I tried to setup a micro project to reproduce this error, and it didn't happened. So I used composer update and I'm not getting the extra migration anymore.

Although, can you explain when I do php bin/console make:migration the script generated uses binary and if I use $schema to be more abstract it uses varbinary?

derrabus commented 8 months ago

Although, can you explain when I do php bin/console make:migration the script generated uses binary and if I use $schema to be more abstract it uses varbinary?

Not without knowing more about your project. And at this point, this issue shifts from a bug report to a support question. Please use StackOverflow, https://github.com/doctrine/orm/discussions/ or https://github.com/symfony/symfony/discussions/ for those.

If you feel like you've hit a bug, feel free to open a new issue with detailed steps for reproducing your bug.