-
Notifications
You must be signed in to change notification settings - Fork 891
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Lower-case default value of TIMESTAMP causes error #2109
Comments
You can open pull request with suggested fix. You can use |
Thanks for your reply. I'll look into doing a pull request. Aha, yeah, |
Maybe the solution in here would be for phinx to not quote functions. In a similar case we want to include a default value for a json in mysql which would be better using the functions included https://dev.mysql.com/doc/refman/8.0/en/json-creation-functions.html |
We have discovered a bug that occurs when using Phinx with MariaDB, and trying to update a TIMESTAMP column with
current_timestamp()
as default value.The error:
PDOException: SQLSTATE[42000]: Syntax error or access violation: 1067 Invalid default value for 'createdAt'
We have found the reason the error occurs. MariaDB is defaulting the TIMESTAMP-value to current_timestamp() in lower-case. There is Phinx code to NOT quote CURRENT_TIMESTAMP in
src/Phinx/Db/Adapter/PdoAdapter.php:getDefaultValueDefinition()
, but because it only handles upper-case, this lower-case default value is quoted anyway.The suggested fix: Adding strtolower around $default and 'CURRENT_TIMESTAMP' in
src/Phinx/Db/Adapter/PdoAdapter.php:getDefaultValueDefinition()
.Is it possible to get this small fix done? :-) Or is there another workaround?
Apparently, MariaDB has changed the default from CURRENT_TIMESTAMP to current_timestamp() from version 10.2.3. (https://mariadb.com/kb/en/now/#description )
Our migration causing the error:
The generated SQL causing the error:
The text was updated successfully, but these errors were encountered: