Search code examples
phpmysqllaraveldatabase-migration

1067 Invalid default value for date 0000-00-00 00:00:00 in Laravel even after removing NO_ZERO_DATE and NO_ZERO_IN_DATE values from sql_mode


I'm trying to run a Laravel migration which is failing at this line

$table->dateTime('start_date')->nullable()->default('0000-00-00 00:00:00');

And I'm getting the following error:

1067 Invalid default value for 'start_date'

even after removing NO_ZERO_DATE and NO_ZERO_IN_DATE values from sql_mode.

I'm using XAMPP, and I ran the following commands:

SET GLOBAL sql_mode=''

SET SESSION sql_mode=''

SET sql_mode=''

I also removed them from the my.ini xampp file, but even after all that, I'm getting the error.

I also tried changing the collation from utf8_general_ci to latin1_swedish_ci but same result. Anyone got any insight on what could be happening?


Solution

  • You can check configuration file in config/database.php in params strict => false should be.