Why $table->timestamps() puts 'ON UPDATE CURRENT_TIMESTAMP' on the created_at column?

Posted 3 years ago by mtctonyhkhk2010

I was trying to set a Message to read using this code

$message->update(['read' => true]);

However, this code updated both created_at and updated_at to current timestamp. I traced the problem and found ON UPDATE CURRENT_TIMESTAMP is set on the created_at column. After I disabled that, the code only update updated_at column as I wanted. So why the migration code $table->timestamps() puts 'ON UPDATE CURRENT_TIMESTAMP' on the created_at column?

Please sign in or create an account to participate in this conversation.