ORM is producing incorrect sql for creating a datetime column with default CURRENT_TIMESTAMP #10586
Unanswered
glenelkinsdev
asked this question in
Support Questions
Replies: 1 comment
-
To add, i had to create a migration and manually change the query to work properly |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
I've just ran into a strange problem that i've never had with doctrine before.
I have an application in symfony 5 using doctrine orm entities, i have used a datetime column with CURRENT_TIMESTAMP as the default many many times and i've never had this issue before.
Take this field:
And now when i run the schema update it would usually create the table no problem, but now i'm getting:
SQLSTATE[42000]: Syntax error or access violation: 1067 Invalid default value for 'date_time'
The sql that doctrine is creating:
The problem seems to be the datetime precision which is set to 6, DATETIME(6) but doctrine isn't using CURRENT_TIMESTAMP(6) so this error is happening.
This code i have used for about a year with no problem, but then i came to rebuild the tables with a schema update on php 5.7 (same as before) and now all of a sudden it's doing this.
Beta Was this translation helpful? Give feedback.
All reactions