【问题标题】:With Symfony2 migrations changes in nullable parameter is not considered使用 Symfony2 迁移时,不考虑可空参数的变化
【发布时间】:2015-01-15 19:40:52
【问题描述】:

我在 Symonfy2 (2.3) 中使用迁移。 当我从以下位置更改任何实体中的字段时:

* @ORM\JoinColumn(nullable=false)

* @ORM\JoinColumn(nullable=true)

然后运行

php app/console doctrine:migrations:diff

然后没有检测到变化。

这是预期的行为吗?如果是,我应该如何更新我的数据库(dev、test、staging 和 prod)?

谢谢

【问题讨论】:

    标签: symfony doctrine doctrine-migrations


    【解决方案1】:

    由于某些原因,我的可为空参数位于另一行,而不是与其他参数位于同一行:

    我有这个:

        /**
     * @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;
    

    而不是这个:

        /**
     * @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;
    

    现在一切都按预期进行。我希望没有人会为此浪费时间...... :(

    【讨论】:

      猜你喜欢
      • 2023-02-26
      • 1970-01-01
      • 2019-03-24
      • 1970-01-01
      • 2019-10-24
      • 2021-11-15
      • 2010-09-22
      • 1970-01-01
      • 2011-03-04
      相关资源
      最近更新 更多