Reputation: 1262
I am currently in the process of migrating a legacy app over to symfony2, the problem is that I have a lot of mysql enum columns, I know that doctrine does not support enum data types and that one workaround is to store as a string but I would really lose the ability to properly sort the data because varchars are a lot slower, I do have a lot of tables with the enum data types and modifying the schema would be really hard, what are my options?? What can you suggest that will make a transition to symfony2 a lot smoother?
Upvotes: 1
Views: 1745
Reputation: 71
Try this it worked for me
http://symfony.com/doc/current/reference/configuration/doctrine.html#reference-dbal-configuration
in the app/config/config.yml file add
mapping_types:
enum: string
e.g below
doctrine:
dbal:
driver: %database_driver%
host: %database_host%
port: %database_port%
dbname: %database_name%
user: %database_user%
password: %database_password%
charset: UTF8
mapping_types:
enum: string
then you can use e.g.
@ORM\Column(type="string", columnDefinition="ENUM('A', 'B')")
Upvotes: 3
Reputation: 4092
You have two solution
for more information please consult this link: Mysql Enums doctrine
Upvotes: 1