duanhuokuang5280 2019-06-05 16:06 采纳率: 100%
浏览 175

在数据库中无法正确识别Doctrine枚举类型

I am trying to add a custom type class for an enum-column to Doctrine, just like in https://www.doctrine-project.org/projects/doctrine-orm/en/2.6/cookbook/mysql-enums.html#solution-2-defining-a-type This type is properly recognized in my schema/annotations, however it is breaks if it is actually used in the database.

I.e., if the column has a different type (f.e. after ALTER TABLE `reservation` CHANGE `city_tax_travel_reason` `city_tax_travel_reason` VARCHAR(255) CHARACTER SET utf8 COLLATE utf8_unicode_ci NOT NULL;), the schema-tool works:

user@srv3:~/portal/bin/app$ ./doctrine orm:schema-tool:update --dump-sql
 The following SQL statements will be executed:
     ALTER TABLE reservation CHANGE city_tax_travel_reason city_tax_travel_reason ENUM('business', 'leisure') NOT NULL COMMENT '(DC2Type:enumtravelreason)';

If I do that, the next call brings back the dreaded invalid type enum-error I try to solve with this class:

user@srv3:~/portal/bin/app$ ./doctrine orm:schema-tool:update --dump-sql --force
 The following SQL statements will be executed:
     ALTER TABLE reservation CHANGE city_tax_travel_reason city_tax_travel_reason ENUM('business', 'leisure') NOT NULL COMMENT '(DC2Type:enumtravelreason)';
 Updating database schema...
     1 query was executed
 [OK] Database schema updated successfully!                                                                             
user@srv3:~/portal/bin/app$ ./doctrine orm:schema-tool:update --dump-sql
In AbstractPlatform.php line 434:
  Unknown database type enum requested, Doctrine\DBAL\Platforms\MySqlPlatform may not support it.  
orm:schema-tool:update [--complete] [--dump-sql] [-f|--force]
user@srv3:~/portal/bin/app$

Am I missing something?

  • 写回答

0条回答

    报告相同问题?

    悬赏问题

    • ¥20 有关区间dp的问题求解
    • ¥15 多电路系统共用电源的串扰问题
    • ¥15 slam rangenet++配置
    • ¥15 有没有研究水声通信方面的帮我改俩matlab代码
    • ¥15 对于相关问题的求解与代码
    • ¥15 ubuntu子系统密码忘记
    • ¥15 信号傅里叶变换在matlab上遇到的小问题请求帮助
    • ¥15 保护模式-系统加载-段寄存器
    • ¥15 电脑桌面设定一个区域禁止鼠标操作
    • ¥15 求NPF226060磁芯的详细资料