Search code examples
symfonydoctrinedoctrine-migrations

With Symfony2 migrations changes in nullable parameter is not considered


I am using migrations in Symonfy2 (2.3). When I change a field in any of my entities from :

* @ORM\JoinColumn(nullable=false)

to

* @ORM\JoinColumn(nullable=true)

And run

php app/console doctrine:migrations:diff

Then no change is detected.

Is this expected behavior? If yes, How should I do to update my databases (dev, test, staging and prod) ?

Thanks


Solution

  • For some reasons, my nullable parameter was on antoher line instead of being on the same line as other parameters :

    I had this:

        /**
     * @var string
     *
     * @ORM\Column(name="persofixe", type="string", length=10, nullable=true)
     * @ORM\Column(nullable=true)
     *
     * @Assert\Regex(
     *     pattern="/^[0]{1}[1-9]{1}[0-9]{8}$/",
     *     message="Le téléphone doit commencer par 0 et contenir 10 chiffres (sans espace ni point).")
     */
    private $persoFixe;
    

    Instead of this:

        /**
     * @var string
     *
     * @ORM\Column(name="persofixe", type="string", length=10, nullable=true)
     *
     * @Assert\Regex(
     *     pattern="/^[0]{1}[1-9]{1}[0-9]{8}$/",
     *     message="Le téléphone doit commencer par 0 et contenir 10 chiffres (sans espace ni point).")
     */
    private $persoFixe;
    

    Now everything is working as expected. I hope nobody will have lost time on this... :(