Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[8.x] Support useCurrentOnUpdate for MySQL datetime column types (#36817
) * Support useCurrentOnUpdate for MySQL datetime column types This commit introduces support `useCurrentOnUpdate` for MySQL datetime column types. MySQL has supported using `ON UPDATE CURRENT_TIMESTAMP` for `DATETIME` columns since `v5.6.5`. Laravel currently previously only supported `useCurrentOnUpdate` for `TIMESTAMP` columns in MySQL. We set the fractional seconds precision to be consistent throughout the column initialization (for the column type, the default, and the on update). MySQL requires that the precision be identical throughout. Note that this implicitly fixed a (likely rare) bug when users tried to run something like `->dateTime('foo', 2)->useCurrent()`. Previously this would result in MySQL error code 1067 for invalid default values. It will not set the default to have the same precision as the column definition. The actual code was borrowed heavily from `typeTimeStamp`. Since they are distinct column types, it felt incorrect to DRY it up despite their similarities. Relevant MySQL documentation: [MySQL 5.6](https://dev.mysql.com/doc/refman/5.6/en/timestamp-initialization.html) [MySQL 5.7](https://dev.mysql.com/doc/refman/5.7/en/timestamp-initialization.html) [MySQL 8.0](https://dev.mysql.com/doc/refman/8.0/en/timestamp-initialization.html) * Use single quotes instead of double quotes when possible
- Loading branch information