yii2-statemachine icon indicating copy to clipboard operation
yii2-statemachine copied to clipboard

Migration

Open Valkinaz opened this issue 6 years ago • 3 comments

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'

Valkinaz avatar Apr 03 '18 10:04 Valkinaz

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

ptheofan avatar Apr 03 '18 11:04 ptheofan

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?

Valkinaz avatar Apr 04 '18 03:04 Valkinaz

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.

ptheofan avatar Apr 10 '20 19:04 ptheofan