Open geoffroyp opened 2 weeks ago
Please share a reproducer for the issue.
Also, which version of doctrine/migrations are you using ?
I am using doctrine/doctrine-migrations-bundle v3.3.1, which itself uses doctrine/migrations v3.7.4
Here's an example of custom type that keeps getting generated, but used to work perfectly before, with DC2Type comments:
<?php
namespace App\Doctrine\Types;
use Doctrine\DBAL\Platforms\AbstractPlatform;
use Doctrine\DBAL\Types\Type;
use Override;
class AmountType extends Type
{
public const AMOUNT = 'amount';
/**
* {@inheritDoc}
*/
#[Override]
public function convertToPHPValue($value, AbstractPlatform $platform): ?float
{
return null !== $value ? (float) $value : null;
}
/**
* {@inheritDoc}
*/
#[Override]
public function getSQLDeclaration(array $column, AbstractPlatform $platform): string
{
$column['precision'] = max($column['precision'], 16);
$column['scale'] = max($column['scale'], 2);
$declaration = 'DECIMAL(' . $column['precision'] . ', ' . $column['scale'] . ')';
$declaration .= $column['unsigned'] ? ' UNSIGNED' : '';
return $declaration;
}
}
and another example:
<?php
namespace App\Doctrine\Types;
use Doctrine\DBAL\Platforms\AbstractPlatform;
use Doctrine\DBAL\Types\IntegerType;
use Override;
class TinyInt extends IntegerType
{
public const string TINYINT = 'tinyint';
/**
* @param array $column
* @param AbstractPlatform $platform
*
* @return string
*/
#[Override]
public function getSQLDeclaration(array $column, AbstractPlatform $platform): string
{
$autoinc = '';
if (!empty($column['autoincrement'])) {
$autoinc = ' AUTO_INCREMENT';
}
return 'TINYINT' . (!empty($column['unsigned']) ? ' UNSIGNED' : '') . $autoinc;
}
public function requiresSQLCommentHint(AbstractPlatform $platform): bool
{
return true;
}
public function getName(): string
{
return self::TINYINT;
}
}
so, when I run make:migration
, then run doctrine:migration:migrate
, then run make:migration
again, every column using one of these customTypes are getting their definition generated every time
Let me know if I shall add more details / code.
Support Question
I have recently upgrade doctrine to DBAL 4 / ORM 3, and when I run make:migration, then run doctrine:migration:migration, then run make:migration again, the exact same file is generated, with the same changes.... From what I see, the big majority of those changes are related to custom doctrine type, and I believe it is related to the fact that "Type::requiresSQLCommentHint()" has been removed from doctrine
My problem seems very similar to https://github.com/doctrine/migrations/issues/1434 that you closed, except that in my case, I'm using MySQL and I removed all comments related to DC2Type. But still, make:migration keeps generating those changes, over and over again.
Any way to fix this?