Laravel API身份验证API向用户迁移表失败

时间:2020-04-18 05:50:39

标签: mysql laravel

步骤1。php工匠make:migration add_api_token_to_users_table --table = users。

步骤2。将其插入架构表api_token_to_users_table。

Schema::table('users', function ($table) {
$table->string('api_token', 80)->after('password')
                    ->unique()
                    ->nullable()
                    ->default(null);
});

第3步。使用php artisan migration运行迁移。

当我运行php artisan migration时,出现此错误。

PDOException::(“” SQLSTATE [42000]:语法错误或访问冲突:1064您的SQL语法有错误;请查看与您的MySQL服务器版本相对应的手册,以找到在'{{之后1}})默认字符集utf8mb4在行1“处整理'utf8mb4_unicode_ci''

Laravel 5.8.38版

1 个答案:

答案 0 :(得分:0)

使用nullable()方法时,该字段将默认设置为NULL。

相关问题