Can anyone please tell me how can I add a new column of type enum to my schema in order to implement a Doctrine Migration?
Make sure that when you are adding new column in your table, that column should be nullable, and should not be unique. Otherwise you will face error. Because when a new column is created it will be empty(not unique). In that condition you have to rollback the migration.
To insert data into an ENUM column, you use the enumeration values in the predefined list. For example, the following statement inserts a new row into the tickets table. In this example, instead of using the Low enumeration value, we used value 1. Since Low is mapped to 1, it is acceptable.
modify your schema
run ./symfony doc:generate-migrations-diff
this will generate one or more files in lib/migrations/doctrine/
run ./symfony doc:migrate
this will apply the generated migrations to the database
run ./symfony doc:build --all-classes
this works for symfony >= 1.3/1.4 and will rebuild all form/filters/model classes according to the modified schema
remember that the migration is generated comparing the new schema.yml to the current model classes, so if you rebuild your classes before running generate-migrations-diff you're screwed.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With