I am trying to run migrations on my Laravel instance. They are just the default migrations (users and password resets) but when it tries to make the timestamps it throws this e
MySQL 5.7.28
The MySQL docs recommend the following (note the use of GLOBAL
):
SET GLOBAL sql_mode = 'ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION';
it sounds like strict mode.
You may disable strict mode in one of two ways:
Open your my.ini file within the MySQL installation directory, and look for the text sql-mode.
Find:
sql-mode="STRICT_TRANS_TABLES,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION"
and change to
sql-mode="NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION"
or you can run the following in phpMyAdmin
SET @@global.sql_mode='';
You can use nullableTimestamps() instead of timestamps()
or else
$table->timestamp('created_at')->default(\DB::raw('CURRENT_TIMESTAMP'));
also, check the database server version
Please have a look on these ref links:
https://github.com/laravel/framework/issues/3602
https://laracasts.com/discuss/channels/forge/syntax-error-or-access-violation-1067-invalid-default-value-for-created-at
This worked for me after being unsuccessful with strict mode:
$table->timestamp('published_on')->useCurrent();