Migration does not detect custom SQLDeclaration change #5308
Open
Description
Bug Report
If declaring custom Type
and its getSQLDeclaration()
method changes, no migration is generated.
Q | A |
---|---|
Version | 3.3.2 |
Summary
Implement ENUM like in the official docs Then if you add/remove new ENUM element, the return value of getSQLDeclaration()
changes. But this is not detected by Comparer and no migration is generated
How to reproduce
Create type:
<?php
namespace MyProject\DBAL;
use Doctrine\DBAL\Types\Type;
use Doctrine\DBAL\Platforms\AbstractPlatform;
class EnumVisibilityType extends Type
{
const ENUM_VISIBILITY = 'enumvisibility';
const STATUS_VISIBLE = 'visible';
const STATUS_INVISIBLE = 'invisible';
public function getSQLDeclaration(array $fieldDeclaration, AbstractPlatform $platform)
{
return "ENUM('visible', 'invisible')";
}
public function convertToPHPValue($value, AbstractPlatform $platform)
{
return $value;
}
public function convertToDatabaseValue($value, AbstractPlatform $platform)
{
if (!in_array($value, array(self::STATUS_VISIBLE, self::STATUS_INVISIBLE))) {
throw new \InvalidArgumentException("Invalid status");
}
return $value;
}
public function getName()
{
return self::ENUM_VISIBILITY;
}
public function requiresSQLCommentHint(AbstractPlatform $platform)
{
return true;
}
}
- Create Entity with column of this type
<?php
/** @Entity */
class Article
{
/** @Column(type="enumvisibility") */
private $status;
}
- Migrate and save DB schema change.
- Change
getSQLDeclaration
to
return "ENUM('visible', 'invisible','halfvisible')";
- Do migrations:diff
Expected behaviour
New migration is created reflecting the change