Conversation
src/Db/Adapter/MysqlAdapter.php
Outdated
| } | ||
| } | ||
| if ($onUpdate !== null && $onUpdate !== '') { | ||
| $column->setUpdate($onUpdate); |
There was a problem hiding this comment.
@markstory is this maybe a bug in the base schema dialect?
It didn't correctly detect the on update CURRENT_TIMESTAMP as it seems - but just for MySQL
There was a problem hiding this comment.
found the issue - the Extra column in that describe query contains
DEFAULT_GENERATED on update CURRENT_TIMESTAMP
as you can see here
[1] =>
array(9) {
'Field' =>
string(7) "created"
'Type' =>
string(8) "datetime"
'Collation' =>
NULL
'Null' =>
string(2) "NO"
'Key' =>
string(0) ""
'Default' =>
string(17) "CURRENT_TIMESTAMP"
'Extra' =>
string(17) "DEFAULT_GENERATED"
'Privileges' =>
string(31) "select,insert,update,references"
'Comment' =>
string(0) ""
}
[2] =>
array(9) {
'Field' =>
string(7) "updated"
'Type' =>
string(8) "datetime"
'Collation' =>
NULL
'Null' =>
string(2) "NO"
'Key' =>
string(0) ""
'Default' =>
string(17) "CURRENT_TIMESTAMP"
'Extra' =>
string(45) "DEFAULT_GENERATED on update CURRENT_TIMESTAMP"
'Privileges' =>
string(31) "select,insert,update,references"
'Comment' =>
string(0) ""
}
mysql> SHOW FULL COLUMNS FROM table1;
+---------+--------------+-----------+------+-----+-------------------+-----------------------------------------------+---------------------------------+---------+
| Field | Type | Collation | Null | Key | Default | Extra | Privileges | Comment |
+---------+--------------+-----------+------+-----+-------------------+-----------------------------------------------+---------------------------------+---------+
| id | int unsigned | NULL | NO | PRI | NULL | auto_increment | select,insert,update,references | |
| created | datetime | NULL | NO | | CURRENT_TIMESTAMP | DEFAULT_GENERATED | select,insert,update,references | |
| updated | datetime | NULL | NO | | CURRENT_TIMESTAMP | DEFAULT_GENERATED on update CURRENT_TIMESTAMP | select,insert,update,references | |
+---------+--------------+-----------+------+-----+-------------------+-----------------------------------------------+---------------------------------+---------+
|
Do we still need all of this with the change made to cake core? |
|
Nope, will re-check this with latest 5.x |
|
So the change in cakephp/cakephp#19207 now causes these tests to fail as the serialized schema dumps do not contain that new property. @markstory @dereuromark I have no idea how those schema-dump files are generated |
2e1218f to
74800c7
Compare
I usually just update those by hand 😊 |
…ate those schema dump files
|
Thanks to Codex we now have a PHP script to automatically update all the Diff Schema Dump Files instead of having to manually adjust/update those serialized dump files whenever we decide/need to change something in our database class properties. |
Since we are now more tightly integrating the migrations plugin with the CakePHP framework I'd propose to change the default
updated/modifiedcolumn type to not be nullable, as by the TimestampBehavior this will always be set.