Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

eggplantSword's avatar

Field 'updated_at' doesn't have a default value error on server

I'm trying to move my project to a droplet but now a lot of stuff doesn't work that does work locally. Right now I'm trying to save a product but I'm getting this error

General error: 1364 Field 'updated_at' doesn't have a default value (SQL: insert into inventory (quantity, product_id) values (0, 6))

I don't get this locally. This is the Inventory Model

    protected $table = 'inventory';
    protected $primaryKey = 'product_id';
    public $timestamps = false;
    protected $dates = ['updated_at'];

    public function setUpdatedAtAttribute($value)
    {
        $this->attributes['updated_at'] = now();
    }

But I'm still getting this error, what could be happening?

Another thing that doesn't work is I have the option to switch between English and Spanish but this also isn't working, again it works locally.

Route::post('/lang', 'DashController@locale');

public function locale(Request $request)
{
    App::setLocale($request->lang);
    session()->put('locale', $request->lang);
    return back();
}

I haven't been able to figure out what else isn't working.

0 likes
5 replies
siangboon's avatar

by default the updated_at should update it automatically but you customize it and set the $timestamps as false...

By default, Eloquent expects created_at and updated_at columns to exist on your tables. If you do not wish to have these columns automatically managed by Eloquent, set the $timestamps property on your model to false

for the language switch, the route is post method, is your blade trigger it within form? otherwise, you may try consider use get method in route

eggplantSword's avatar

@siangboon I don't see how it would work locally but not when put on a server, especially when this method is correct.

Snapey's avatar

probably some letter case issue somewhere...

also, have a look at the table definition on your local machine. You may have made the column nullable at some time then forgot to add it to your database migrations.

eggplantSword's avatar

@snapey I ended up just using the regular timestamps saved me the time of trying to figure out what happened

siangboon's avatar

system is built as that way, how the local work but not the production issue is not uncommon problem in this forum... the main reason is careless with some typo errors... or misconfiguration at production as from local that user always were not aware but claimed that it's identical settings...

Please or to participate in this conversation.