Php 尝试添加主键时出错';使用laravel的s数据类型字符串
我的密码在这里Php 尝试添加主键时出错';使用laravel的s数据类型字符串,php,mysql,laravel,Php,Mysql,Laravel,我的密码在这里 public function up() { Schema::create('semesters', function (Blueprint $table) { // $table->increments('id'); $table->engine = 'InnoDB'; $table->string('semester_id')->unique()->u
public function up()
{
Schema::create('semesters', function (Blueprint $table) {
// $table->increments('id');
$table->engine = 'InnoDB';
$table->string('semester_id')->unique()->unsigned();
$table->timestamps();
});
}
这里有错误
[Illumb\Database\QueryException]SQLSTATE[42000]:语法错误
或访问冲突:1064您的SQL语法有错误;检查
与的MariaDB服务器版本相对应的手册
使用“unsigned not null,created_在
times tamp”附近的正确语法
默认0不为空,在第1行的
时间更新(SQL:create table
学期
(学期id
文本未签名不为空,在
时间戳默认值0不为空,在更新时
时间戳默认值0不为空
null)默认字符s et utf8 collate utf8\u unicode\u ci引擎=
InnoDB)
您可以混合使用以下类型:
string
和unsigned
(即int)
因此,如果需要将此列设置为字符串,则应在此处删除未签名部分
:
$table->string('semester_id')->unique()->unsigned(); <---
你不混合打字吗<代码>字符串VS
无符号
?尝试更改为$table->integer('serment_id')->unique()->unsigned()
toi要将字符串数据类型添加到我的主键o remove->unsigned()代码>第二部分谢谢你为我做的这项工作:)@muhammadarslan,如果它对你有用,你应该接受Alex的回答:
$table->string('semester_id')->unique();