I am trying to create a custom Doctrine mapping type, as per: http://doctrine-orm.readthedocs.org/projects/doctrine-dbal/en/latest/reference/types.html#custom-mapping-types
My class is as follows:
<?php
namespace AppBundle\Doctrine\Type;
use Doctrine\DBAL\Types\Type;
use Doctrine\DBAL\Platforms\AbstractPlatform;
/**
* My custom datatype.
*/
class BinaryStringType extends Type
{
public function getSQLDeclaration(array $fieldDeclaration, AbstractPlatform $platform)
{
return $platform->getBinaryTypeDeclarationSQL($fieldDeclaration);
}
public function getDefaultLength(AbstractPlatform $platform)
{
return $platform->getVarcharDefaultLength();
}
public function getName()
{
return 'binarystring';
}
}
?>
And in config.yml doctrine
section:
dbal:
types:
binarystring: AppBundle\Doctrine\Type\BinaryStringType
It (kind of) works, but: running php bin/console doctrine:schema:update
ALWAYS generates an ALTER TABLE statement, no matter if database is up to date or not.
ALTER TABLE xxxx CHANGE column column VARBINARY(24) DEFAULT NULL;
Any ideas how to fix this?
thanks!
ALTER TABLE
statement, what is the exact statement that it generates? – Jason Romanalter table
statement to the question. – Karolis