【发布时间】:2019-05-17 16:44:07
【问题描述】:
我在迁移表时遇到错误。 错误说
SQLSTATE[42000]:语法错误或访问冲突:1064 你有一个 SQL 语法错误;检查与您对应的手册 MariaDB 服务器版本,用于在 'json null 附近使用正确的语法,
start_date日期不为空,end_date日期不为空,status枚举('' 在第 1 行 (SQL: 创建表modules(idint unsigned not null auto_increment 主键,titlevarchar(191) 不为空,descriptiontext not null,imageblob null,resourcesjson null,start_date日期不为空,end_date日期不为空,statusenum('pending', 'start', 'completed') not null 默认 'pending',user_idint 不为空,created_at时间戳为空,updated_attimestamp null) 默认字符集 utf8mb4 collate 'utf8mb4_unicode_ci')
我的表有以下值:
public function up()
{
Schema::create('modules', function (Blueprint $table) {
$table->increments('id');
$table->string('title');
$table->text('description');
$table->binary('image')->nullable();
$table->json('resources')->nullable();
$table->date('start_date');
$table->date('end_date');
$table->ENUM('status',['pending','start','completed'])->default('pending');
$table->integer('user_id');
$table->timestamps();
});
}
这是我的模型代码:
<?php
namespace App;
use Illuminate\Database\Eloquent\Model;
class modules extends Model
{
protected $fillable = [
'title', 'description','image','resources', 'start_date','end_date','status','user_id',
];
}
谁能解决这个问题??
【问题讨论】:
-
发布您的型号代码
-
我已经发过了,现在你能帮我吗
-
检查您的 MariaDB 版本。从 MariaDB 文档中,“在 MariaDB 10.2.7 中添加了 JSON 别名。这样做是为了可以在从 MySQL 到 MariaDB 的基于语句的复制中使用 JSON 列,并使 MariaDB 可以从 MySQL 读取 mysqldumps。” mariadb.com/kb/en/library/json-data-type
-
您使用的是什么版本的 MariaDB?
-
还将您的 Laravel 版本添加到您的问题中。