Skip to content
This repository has been archived by the owner on Oct 28, 2020. It is now read-only.

Syntax error or access violation: 1067 Invalid default value for 'created_at #12

Closed
popiciulo opened this issue Jun 9, 2019 · 5 comments

Comments

@popiciulo
Copy link

Hi, I am getting this error: "Syntax error or access violation: 1067 Invalid default value for 'created_at" when I migrate the generated migrations.
If I replace the generated timestamp('created_at') and timestamp('updated_at') with timestamps() then this error is gone.
I am using Laravel 5.8.

@calvinchiulele
Copy link

This is because the $table->timestamps('created_at') statement doesn't include a default value for the timestamps column. We should make a PR to fix that bug. To fix this, we have to write the follow in the migration file:
$table->timestamp('created_at')->nullable();
$table->timestamp('updated_at')->nullable();

You can use $table->timestamps() instead.

@ajthinking
Copy link
Member

Thanks for reporting @PopescuMarian ! That one slid right through when using sqlite. Im looking into it now.

@ajthinking
Copy link
Member

Added to this Trello board. Did not make it today, coming back tomorrow. Thanks @calvinchiulele for pointing out the reason!

@sinaghazi
Copy link

sinaghazi commented Jun 10, 2019

as a quick fix on this, on line 85 of AttributeFactory.js you can change the getNullable method to:

getNullable() {
        if (this.getForeign() || ['created_at', 'updated_at'].includes(this.name)){
            return true;
        }else{
            return false;
        }
    }

@ajthinking
Copy link
Member

Fix for the default timestamps released in v0.0.44. Further updates to come later. Thanks yall!

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants