yii2-statemachine
yii2-statemachine copied to clipboard
Migration
Hello.
Migration m160703_001232_initStateMachineMigrations
has a problem with table sm_timeout
column expires_at
.
Exception 'yii\db\Exception' with message 'SQLSTATE[42000]: Syntax error or access violation: 1067 Invalid default value for 'expires_at'
Hey man,
this is a legit value for mysql/mariadb timestamp columns. https://dev.mysql.com/doc/refman/5.7/en/timestamp-initialization.html
Issue might be sql strict mode setting or mysql version you are using. The following link might help you solve it in your installation. https://stackoverflow.com/questions/36374335/error-in-mysql-when-setting-default-value-for-date-or-datetime/40075057
Yes, it is strict mode. But why we need to set non-existent date as default value? I think NULL will be better or maybe CURRENT_TIMESTAMP?
The current timestamp will not work as it would instantly expire the row. Setting null is an option and will require some updates in the code. Code contributions are most welcomed.