Reputation: 21
i get this error when i am trying to set the column type to datetime
/**
** @var \DateTime
*
* @ORM\Column(type="datetime")
*/
private $timestamp;
Error:
[Doctrine\DBAL\Exception\DriverException]
An exception occurred while executing 'ALTER TABLE fos_user CHANGE timestamp
timestamp DATETIME DEFAULT NULL':
SQLSTATE[22007]: Invalid datetime format: 1292 Incorrect datetime value: ''
for column 'timestamp' at row 1
Upvotes: 0
Views: 7620
Reputation: 1
I had the same issue in Symfony 5+ and this one worked for me
$this->addSql('ALTER TABLE _yourTableName ADD date DATE NULL DEFAULT NULL');
Then make your migration .
Upvotes: 0
Reputation: 334
Set NULL for all records where timestamp = '' and then try you update one more time.
It seems you already have timestamp column and try to migrate it to 'DATETIME DEFAULT NULL'. But because some of records have empty strings ('') which are not NULL or date values it raised an error.
Upvotes: 7