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

    报告相同问题?

    悬赏问题

    • ¥35 平滑拟合曲线该如何生成
    • ¥100 c语言,请帮蒟蒻写一个题的范例作参考
    • ¥15 名为“Product”的列已属于此 DataTable
    • ¥15 安卓adb backup备份应用数据失败
    • ¥15 eclipse运行项目时遇到的问题
    • ¥15 关于#c##的问题:最近需要用CAT工具Trados进行一些开发
    • ¥15 南大pa1 小游戏没有界面,并且报了如下错误,尝试过换显卡驱动,但是好像不行
    • ¥15 自己瞎改改,结果现在又运行不了了
    • ¥15 链式存储应该如何解决
    • ¥15 没有证书,nginx怎么反向代理到只能接受https的公网网站