Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Doctrine migrations keeps generating datetime field over and over again

I use Symfony 2.1.* with Doctrine 2.3.* and I am having the following problem:

When generating migrations for my mysql (5.5) database, it keeps generating queries for my datetime fields.

My model looks like this:

class User {
    /**
     * @var \DateTime $createdAt
     *
     * @ORM\Column(type="datetime", nullable=true, options={"default"=null})
     */
    private $createdAt;

    /**
     * @var \DateTime $updatedAt
     *
     * @ORM\Column(type="datetime", nullable=true, options={"default"=null})
     */
    private $updatedAt;
}

And this is the migration that gets generated every single time:

$this->addSql("ALTER TABLE user CHANGE created_at created_at DATETIME DEFAULT NULL, CHANGE updated_at updated_at DATETIME DEFAULT NULL");

It's driving me nuts, since I do a lot of restructuring and every time I have to remove these queries for +/- 15 different entities.

Is this a known issue, or am I doing something wrong?

like image 345
Robbert van den Bogerd Avatar asked Mar 15 '13 14:03

Robbert van den Bogerd


1 Answers

As @BetaRide mentions above, you should just remove the options={"default"=null}

like image 51
Robbert van den Bogerd Avatar answered Sep 30 '22 17:09

Robbert van den Bogerd