Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Migrations] Schema builder exception, syntax error, invalid default value for created_at field #94

Open
Mounika-Akula opened this issue Aug 28, 2016 · 2 comments
Labels

Comments

@Mounika-Akula
Copy link

migration_schema_builder_datetime_error
Exception throws for created_at "DATETIME" field when I try to execute Migration for for category table schema.

Configuration: PHP 7 & MYSQL 5.7.9.

Reference screenshot attached

@sanjoydesk
Copy link
Member

sanjoydesk commented Aug 28, 2016

It is known issue on higher version of MYSQL (5.7.*). You can pass the default value for the DATETIME field "created_at" or "updated_at" to your schema while executing migration as below.

Schema::make('category', function ($table)
{
        $table->create([
               ['column'=> 'created_at', 
                'type' => 'datetime', 'length' => 'NOT NULL DEFAULT NOW()'],
                ['column'=> 'updated_at', 'type' => 'datetime', 
                 'length' => 'DEFAULT NOW()'],
                ['column'=> 'time_logged', 'type' => 'datetime', 'length' => 'null'],
         ], 'InnoDB', 'latin1');
});

We will work on it, we will add a default value as null for DATETIME field. Thanks!

@Mounika-Akula
Copy link
Author

Thank you Sanjoy :P

On Sun, Aug 28, 2016 at 10:33 PM, Sanjoy Dey [email protected]
wrote:

It is known issue on higher version of MYSQL (5.7.*). You can pass the
default value for DATETIME field "created_at" or "updated_at" to your
schema while executing migration as below.

Schema::make('category', function ($table)
{
$table->create([
['column'=> 'created_at',
'type' => 'datetime', 'length' => 'NOT NULL DEFAULT NOW()'],
['column'=> 'updated_at', 'type' => 'datetime',
'length' => 'DEFAULT NOW()'],
['column'=> 'time_logged', 'type' => 'datetime', 'length' => 'null'],
], 'InnoDB', 'latin1');
});

However we will work on this issue asap.


You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
#94 (comment),
or mute the thread
https://github.com/notifications/unsubscribe-auth/ALgtv_M41sg-ufF-FhVGWXTz-lIhKi4_ks5qkb9kgaJpZM4Ju9b2
.

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

No branches or pull requests

2 participants