9

Please help me to understand how to do this in Laravel 5.4. Can't google this.

CREATE TABLE t1 (
  dt DATETIME DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP
);

This is not working:

$table->dateTime('dt')
        ->default(DB::raw('CURRENT_TIMESTAMP'))
        ->onUpdate(DB::raw('CURRENT_TIMESTAMP'));

The question is about THIS PART:

ON UPDATE CURRENT_TIMESTAMP

SOLVED:

Well, solution was simple :/

$table->dateTime('updated')
        ->default(DB::raw('CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP'))
Rob
  • 2,243
  • 4
  • 29
  • 40
a.anon
  • 158
  • 2
  • 8

0 Answers0