首页 > 解决方案 > PDOException::("SQLSTATE[42000]: 语法错误或访问冲突

问题描述

我正在使用 xamp、mysql 和 laravel 6 并使用 spatie 媒体库进行图像上传,我在迁移文件时遇到了问题,我的错误是

PDOException::("SQLSTATE[42000]: 语法错误或访问冲突:1064 您的 SQL 语法有错误;请查看与您的 MariaDB 服务器版本相对应的手册,了解在 'json not null, custom_propertiesjson附近使用的正确语法不为空, responsive_images第 1 行的 json 不是 n'")

PDO::prepare("创建表media( idint unsigned not null auto_increment 主键, model_typevarchar(191) not null, model_idchar(36) not null, collection_namevarch ar(191) not null, namevarchar(191) not null, file_namevarchar(191) not null, mime_typevarchar(191) null, diskvarchar(191) not null, size int unsigned not null, manipulatio nsjson not null, custom_propertiesjson not null, responsive_imagesjson not null, order_columnint unsigned null, created_attimestamp null, updated_attimestamp null) 默认字符集 utf8mb4 collat​​e ' utf8mb4_unicode_ci'")

我的迁移文件

Schema::create('media', function (Blueprint $table) {
            $table->increments('id');
            $table->string('model_type');
            $table->uuid('model_id');
            $table->string('collection_name');
            $table->string('name');
            $table->string('file_name');
            $table->string('mime_type')->nullable();
            $table->string('disk');
            $table->unsignedInteger('size');
            $table->json('manipulations');
            $table->json('custom_properties');
            $table->json('responsive_images');
            $table->unsignedInteger('order_column')->nullable();
            $table->nullableTimestamps();

标签: laravelmariadb

解决方案


推荐阅读