0

when i try to make stricton value to TRUE then it shows error Error Number: 1364 Field 'modified_at' doesn't have a default value" and when try to make it FALSE then it shows error

Variable 'sql_mode' can't be set to the value of 'REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE( @@sql_mode'
SELECT GET_LOCK('ad3549572403a9c71bea1109d26f4b48', 300) AS ci_session_lock

when the value is true, everything is working but i need to refresh to make error: "Error Number: 1364 Field 'modified_at' doesn't have a default value" gone. please help me to overcome this fault. thank uu!

Here is the screenshot of the errors:

enter image description here

enter image description here

2 Answers2

3

Make this column nullable.Beacuse here modified_at is not nullable.When you a save a row data you passed every element but you didn't save any data into modified_at. so make this column nullable.

$table->date('modified_at')->nullable();

If you haven't enough data then

php artisan migrate:refresh

If you have enough data on database & don't wabt to refresh it then add a new migration file. & make this column nullable.like

Schema::table('your_table_name', function (Blueprint $table) {
    $table->string('modified_at')->nullable()->change();
});

For details https://laravel.com/docs/5.8/migrations#modifying-columns

albus_severus
  • 3,626
  • 1
  • 13
  • 25
0

you are not passing the value to 'modified_at' column when inserting the data so the error is thrown.

You should either make that column have a default value or seeing the column name I guess making it nullable will do.

(Assuming the column is a date field and using Laravel)

You will have to use Column modifier ->nullable()

Migration:

$table->date('modified_at')->nullable();

.

Anuj Shrestha
  • 966
  • 6
  • 18