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

我正在尝试将一个枚举列的自定义类型类添加到Doctrine,就像在 https: //www.doctrine-project.org/projects/doctrine-orm/en/2.6/cookbook/mysql-enums.html#solution-2-defining-a-type
此类型在我的架构中被正确识别 /注释,但如果它实际上在数据库中使用则会中断。</ p>

即如果列具有不同的类型(在 ALTER TABLEreservation之后改变更改city_tax_travel_reason `city_tax_travel_reason VARCHAR(255)CHARACTER SET utf8 COLLATE utf8_unicode_ci NOT NULL; </ code>),架构工具有效:</ p>

 <  code> user @ srv3:〜/ portal / bin / app $ ./doctrine orm:schema-tool:update --dump-sql 
将执行以下SQL语句:
ALTER TABLE reservation CHANGE city_tax_tr avel_reason city_tax_travel_reason ENUM('business','leisure')NOT NULL COMMENT'(DC2Type:enumtravelreason)';
</ code> </ pre>

如果我这样做,下一个电话会带回来 我尝试用这个类解决的可怕的无效类型枚举错误:</ p>

  user @ srv3:〜/ portal / bin / app  $ ./doctrine orm:schema-tool:update --dump -sql --force 
将执行以下SQL语句:
ALTER TABLE预留CHANGE city_tax_travel_reason city_tax_travel_reason ENUM('business','leisure')NOT NULL COMMENT '(DC2Type:enumtravelreason)';
正在更新数据库架构...
1执行了查询
[确定]数据库架构已成功更新!

user @srv3:〜/ portal / bin / app $ ./doctrine orm:schema-tool:update --dump-sql
在AbstractPlatform.php第434行:
请求未知的数据库类型枚举,Doctrine \ DBAL \ Platforms \ MySqlPlatform可能不支持它。

orm:schema-tool:update [--complete] [--dump-sql] [-f | --force]
user @srv3:〜/ portal / bin / app $
</ code> </ pre >

我错过了什么吗?</ p>
</ div>

展开原文

原文

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?

Csdn user default icon
上传中...
上传图片
插入图片
抄袭、复制答案,以达到刷声望分或其他目的的行为,在CSDN问答是严格禁止的,一经发现立刻封号。是时候展现真正的技术了!
立即提问
相关内容推荐