My project working on Symfony 4.4 and doctrine migrations bundle 3.2.1.
I used the columnDefinition to write a special column:
columnDefinition="VARCHAR(50) GENERATED ALWAYS AS (IF(ISNULL(`cabinet_id`), 'null', `cabinet_id`)) VIRTUAL"
It works perfect, but now, every time when I call doctrine:migrations:diff
, migration is trying to change the column for the same:
ALTER TABLE MonitoringReportUpdate CHANGE virtual_null `virtual_null` VARCHAR(50) GENERATED ALWAYS AS (IF(ISNULL(`cabinet_id`), \'null\', `cabinet_id`)) VIRTUAL
And even if I run this alter, and call doctrine:migrations:diff
again, I'll see the same query to execute:
ALTER TABLE MonitoringReportUpdate CHANGE virtual_null `virtual_null` VARCHAR(50) GENERATED ALWAYS AS (IF(ISNULL(`cabinet_id`), \'null\', `cabinet_id`)) VIRTUAL
Did I use columnDefinition wrong or maybe it's just a bug? Or is it possible to ignore this column when I call generate migration?
This is something Doctrine is not able to analyze properly so he is not able to consider it "already done", so he is considering it missing each time you generate a diff. I already had to try such "complex" doctrine column def and i did not found a good workaround.
My best answer would be : There is something bad in your code that generate that kind of needed behavior in your database : avoid it and adapt your code.