Laravel 5: $table->timestamps() breaks postgres

555 views Asked by At

I have a table migrated with php artisan. It has timestamps:

$table->timestamps();

When I seed his table with MYSQL: it's fine. However when I do that with Postgres, I get this error:

ERROR:  null value in column "updated_at" violates not-null constraint
DETAIL:  Failing row contains

Is this because I have indexing for my timestamps?

$table->index('created_at');
$table->index('updated_at');

What can I do? Not use updated_at indexing? Define the timestamps as ->nullable();?

1

There are 1 answers

0
Bogdan On BEST ANSWER

The error you get makes the solution pretty obvious: make the column nullable. You can use the dedicated nullableTimestamps method to make it easier:

$table->nullableTimestamps();