When I run this command at first, everything seems to work fine :
$ php bin/console doctrine:schema:update --dump-sql
ALTER TABLE posts CHANGE createdAt createdAt DATETIME NOT NULL, CHANGE updatedAt updatedAt DATETIME DEFAULT NULL;
$ php bin/console doctrine:schema:update --force
Updating database schema...
Database schema updated successfully! "1" query was executed
But when I re-run a dump-sql
, it's like the update hasn't happened :
$ php bin/console doctrine:schema:update --dump-sql
ALTER TABLE posts CHANGE createdAt createdAt DATETIME NOT NULL, CHANGE updatedAt updatedAt DATETIME DEFAULT NULL;
I can repeat that endlessly.
Here is my Post
entity with the createdAt
and updatedAt
properties annotations :
<?php
namespace WebBundle\Entity;
use Doctrine\ORM\Mapping as ORM;
/**
* Post
*
* @ORM\Table(name="posts")
* @ORM\Entity(repositoryClass="WebBundle\Repository\PostRepository")
*/
class Post
{
...
/**
* @var \DateTime
*
* @ORM\Column(name="createdAt", type="datetimetz")
*/
private $createdAt;
/**
* @var \DateTime
*
* @ORM\Column(name="updatedAt", type="datetimetz", nullable=true)
*/
private $updatedAt;
And when I check my MariaDB table, the schema is exactly what I declared :
# Name Type Collation Attributes Null Default Extra
1 id char(36) No None
...
7 createdAt datetime No None
8 updatedAt datetime Yes NULL
Any idea about what's wrong ?
i Have exactly the same problem !
I rename the field type "datetimez" to "datetime" and now it is ok
/**
* @var \DateTime
*
* @ORM\Column(name="created", type="datetime")
*/
private $created;
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With