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条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥60 更换迈创SOL6M4AE卡的时候,驱动要重新装才能使用,怎么解决?
    • ¥15 让node服务器有自动加载文件的功能
    • ¥15 jmeter脚本回放有的是对的有的是错的
    • ¥15 r语言蛋白组学相关问题
    • ¥15 Python时间序列如何拟合疏系数模型
    • ¥15 求学软件的前人们指明方向🥺
    • ¥50 如何增强飞上天的树莓派的热点信号强度,以使得笔记本可以在地面实现远程桌面连接
    • ¥20 双层网络上信息-疾病传播
    • ¥50 paddlepaddle pinn
    • ¥20 idea运行测试代码报错问题