我添加了一个自定义类型,例如:
namespace My\SuperBundle\Types;
use Doctrine\DBAL\Types\Type;
use Doctrine\DBAL\Platforms\AbstractPlatform;
class Money extends Type
{
const MONEY = 'money';
public function getSqlDeclaration(
array $fieldDeclaration,
AbstractPlatform $platform
) {
return 'DECIMAL(10,2)';
}
public function getName()
{
return self::MONEY;
}
}
在我的应用程序引导中:
namespace My\SuperBundle;
use Doctrine\DBAL\Types\Type;
use My\SuperBundle\Types\Money;
class MyBSuperBundle extends Bundle
{
public function boot()
{
//add custom quantity and wight types
$em = $this->container->get('doctrine.orm.entity_manager');
if(!Type::hasType(Money::MONEY)) {
Type::addType(Money::MONEY, 'My\SuperBundle\Types\Money');
}
}
}
无论何时我使用以下代码更新数据库:
php app/console doctrine:schema:update --dump-sql
我不断收到以下内容:
ALTER TABLE product_price CHANGE price price DECIMAL(10,2) DEFAULT NULL
除此之外一切都运行得非常好。数据库中的字段是正确的。 Doctrine为什么会一直更新相同的数据?