php - 更改列类型 Laravel 5
问题描述
为什么我会收到以下错误
SQLSTATE[42000]: Syntax error or access violation: 1064 You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'NOT NULL
COLLATE utf8mb4_unicode_ci' at line 1 (SQL: ALTER TABLE questions CHANGE category_id category_id INT DEFAULT NOT NULL COLLATE utf8mb4_unicode_ci)
SQLSTATE[42000]: Syntax error or access violation: 1064 You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'NOT NULL
COLLATE utf8mb4_unicode_ci' at line 1
通过执行以下代码:
Schema::table('questions', function(Blueprint $table) {
$table->integer('category_id')->unsigned()->change();
});
解决方案
unsignedInteger
改为使用
Schema::table('questions', function(Blueprint $table) {
$table->unsignedInteger('category_id')->change();
});
推荐阅读
- reactjs - 如何在静态 S3/CloudFront 网站托管上呈现动态 Next.js 路径?
- events - 进入可编辑单元格时的 RowSelectionChanged-Event(要求:取决于 F4 OVS)
- node.js - nodejs删除文件:TypeError:promises_1.rm不是函数
- android - Kotlin:无法在列表中获取对象获取器
- python - 如何在 pyOpenSSL 中设置密码模式?
- r - 我可以在同一个图中组合面积图和条形图吗?
- flutter - Flutter 集成测试的热重载?
- asp.net-core-3.1 - 重做侧边菜单
- android - 尝试在空对象引用上调用接口方法“____”
- java - Gradle 的几个问题