mysql - Laravel API Authentication api 向用户迁移表失败
问题描述
步骤 1. php artisan 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 migrate 运行 migrate。
当我运行 php artisan migrate 时,出现此错误。
PDOException::("SQLSTATE[42000]: 语法错误或访问冲突:1064 您的 SQL 语法有错误;请查看与您的 MySQL 服务器版本相对应的手册,以获取在 'after 附近使用的正确语法password
) 默认字符集 utf8mb4在第 1 行整理“utf8mb4_unicode_ci”)
Laravel 版本 5.8.38
解决方案
当您使用 nullable() 方法时,该字段将默认设置为 NULL。
推荐阅读
- android - android.system.ErrnoException: ioctl failed: EBADF (Bad file descriptor) with file from data/data 文件夹
- android - 操作栏不可见?
- javascript - 在反应 DRY 中稍微适应了 HOC
- swift - 如何使用 Google idToken、accessToken 从我的托管服务器到我的应用程序?
- php - php-cs-fixer : 保持大括号在函数声明的同一行
- c# - .NET 的 Ghostscript 版本
- laravel-5 - 对数组使用同步方法并添加额外的数据透视字段?
- reactjs - 传递数据
- firebase - 如何立即在从相机拍摄的屏幕上显示图像?
- android - 在 android 计费活动上付款成功后没有任何反应