Doctrine orm 删除列时使用原则迁移
我们在Doctrine orm 删除列时使用原则迁移,doctrine-orm,zend-framework2,Doctrine Orm,Zend Framework2,我们在\doctor\DBal\Types\type::addType()中添加了一个名为enumFooType的枚举列类型 运行vendor/bin/doctor模块迁移:diff以生成将删除所述列的迁移时,抛出一个错误: [Doctrine\DBAL\DBALException] Unknown column type "enumFooType" requested. Any Doctrine type that you use has to be registered with \Do
\doctor\DBal\Types\type::addType()
中添加了一个名为enumFooType
的枚举列类型
运行vendor/bin/doctor模块迁移:diff
以生成将删除所述列的迁移时,抛出一个错误:
[Doctrine\DBAL\DBALException]
Unknown column type "enumFooType" requested. Any Doctrine type that you use has to be registered with \Doctrine\DBAL\Types\Type::addType().
You can get a list of all the known types with \Doctrine\DBAL\Types\Type::getTypesMap().
If this error occurs during database introspection then you might have forgot to register all database types for a Doctrine Type.
Use AbstractPlatform#registerDoctrineTypeMapping() or have your custom types implement Type#getMappedDatabaseTypes().
If the type name is empty you might have a problem with the cache or forgot some mapping information.
我猜抛出错误是因为数据库有一个foo\u类型
标记为(DC2Type:enumFooType)
处理这些类型的删除的正确方法是什么?我的第一个想法是使用供应商/bin/doctor模块迁移生成一个空白迁移:生成并手动编写查询,但我希望使用一种更自动化的方式,如果可能的话,不需要手动编写任何内容。TL;医生: DBAL类型
EnumFootType
的类定义应该在运行条令命令之前存在(现在我已经写了这一行,感觉有点明显,比如“duh!”)
长答案:
经过几次回滚和反复试验,我为此类操作设计了以下过程:
EnumFootType
的属性EnumFooType
文件仍然存在)EnumFootType
类EnumFooType
存在,并且在实体类中定义类型EnumFooType
的属性