I'd like to address question to those who use Mysql + Doctrine ORM + Doctrine migrations I have an association:
/**
* @var User
*
* @ORM\ManyToOne(targetEntity="User")
* @ORM\JoinColumn(nullable=true)
*/
protected $sender;
(key point here is nullable=true. Some attributes are left behind intentionally)
- i do
migraions:diff- generated migration with a piecesender_id VARCHAR(255) DEFAULT NULL - run migrate
- then i do
diffagain, expecting no new migrations generated - but no, i see new file with line
CHANGE sender_id sender_id VARCHAR(255) DEFAULT NULL
It means that nothing is going to be changed, however doctrine dbal under Mysql driver doesn't see from entity annotations that DEFAULT NULL
I tried to add @ORM\Column(options={"default": NULL}).
That helped with preventing DEFAULT NULL in migrations, but FK and Index were dropped in this case.
Tried also add columnDefinition="VARCHAR(255) DEFAULT NULL" but also didn't work
How did you solve this issue?