Json数据类型在Schera Laravel 5.2中不起作用

时间:2016-08-09 13:38:05

标签: json schema laravel-5.2

Laravel 5.2.42

当我在cmd php artisan migrate中运行此代码时出现此错误

[Illuminate\Database\QueryException]
SQLSTATE[42000]: Syntax error or access violation: 1064 You have an error in your SQL 
syntax; check the manual that corresponds to your MySQL server version for the right 
syntax to use near 'json not null) default character set utf8 collate utf8_unicode_ci' 
at line 1 (SQL: create table `checkouts` (`id` int unsigned not null auto_increment 
primary key, `user_id` int not null, `stuff` json not null) default character set utf8 
collate utf8_unicode_ci)

这是我的结帐表格迁移:

<?php

use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;

class CreateCheckoutsTable extends Migration
{
    public function up()
    {
        Schema::create('checkouts', function (Blueprint $table) {
            $table->increments('id');
            $table->integer('user_id');
            $table->json('stuff');
            $table->timestamps();
        });
    }

    public function down()
    {
        Schema::drop('checkouts');
    }
}

模型 Checkout.php     

namespace App;

use Illuminate\Database\Eloquent\Model;

class Checkout extends Model
{
    protected $table = 'checkouts';

    protected $casts = ['stuff' => 'json'];
}


我该如何解决这个问题?还是有另一种想法在架构中创建数组数据类型?

0 个答案:

没有答案