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
    文件仍然存在)
  • 删除包含此dbal类型定义的
    EnumFootType
  • 必须按此顺序执行的原因是,如果先删除类型,则不会加载条令,因为此文件丢失,导致原始问题中出现异常

    此外,在创建了迁移之后,然后删除了类型;如果您需要回滚该更改,您必须:

  • 还原到上一次提交,以便
    EnumFooType
    存在,并且在实体类中定义类型
    EnumFooType
    的属性
  • 运行migration命令以回滚