首页 > 解决方案 > Laravel 迁移修饰符 ->after('column') 不起作用

问题描述

为表设置迁移。

Schema::create('users', function (Blueprint $table) {
            $table->bigIncrements('id');
            $table->string('name');
            $table->string('email')->unique();
            $table->timestamp('email_verified_at')->nullable();
            $table->string('password');
            $table->rememberToken();
            $table->timestamps();
            $table->unsignedBigInteger('created_by')->nullable()->after('created_at');
        });

问题在于->after('created_at').

Illuminate\Database\QueryException : SQLSTATE[42000]: 语法错误或访问冲突:1064 您的 SQL 语法有错误;检查与您的 MySQL 服务器版本相对应的手册,以created_at在第 1 行的默认字符集 utf8mb4 collat​​e 'utf8mb4_unicode_ci'' 附近使用正确的语法(SQL:创建表 usersidbigint unsigned not null auto_increment 主键, namevarchar(255) not null, emailvarchar(255) not null, email_verified_attimestamp null, passwordvarchar(255) not null, remember_tokenvarchar(100) null, created_attimestamp null, updated_attimestamp null, created_bybigint unsigned null after created_at) 默认字符集 utf8mb4 collat​​e 'utf8mb4_unicode_ci')]

我正在使用 Laragon 开发平台。

mysql Ver 14.14 Distrib 5.7.24,适用于 Win64 (x86_64)

标签: laravel

解决方案


推荐阅读