Fahmi Fahmi - 1 year ago 41
SQL Question

MySQL modified the "Default" and "Extra" value for timestamp fields

I'm using Laravel migrations to create

table. It has
fields which have been created using

The resulting table structure looks like this;

enter image description here

Why do both of the timestamp fields have a default value? As far as I'm concerned Laravel migrations
doesn't set the default value for timestamp.

Also, the
field's "Extra" has been set to
. I don't think Laravel migrations set this either.

Does anyone know why MySQL behave this way? I'm using MySQL 5.7.10 by the way.

UPDATE: As of Laravel v5.2.24 timestamps have been made nullable by default, so this won't be a problem anymore - commit

Answer Source

This is related to differences between MySQL versions and strict mode, specifically <= 5.6 and 5.7 as strict mode is now enabled by default. See https://github.com/laravel/framework/issues/11518

The solution for now seems to be either use $table->nullableTimestamps() or manually defining both created_at and updated_at columns as below