public function up()
{
Schema::create('tests', function (Blueprint $table) {
$table->string('id',18);
$table->primary('id');
$table->integer('a',10)->nullable()->comment("aaaaaa");
$table->string('b',20)->nullable()->comment("bbbbbb");
$table->integer('c')->default(0)->comment("aaaaa");
});
}
今天发现一个问题数据写入不了表,这张表是上次建的,结果我打开表发现结构不对。我又测试了一下,结果报错
[Illuminate\Database\QueryException]
SQLSTATE[42000]: Syntax error or access violation: 1068 Multiple primary key defined (SQL: alter table `tests` add primary key `tests_id_primary`(`id`))
[PDOException]
SQLSTATE[42000]: Syntax error or access violation: 1068 Multiple primary key defined
没看懂 为什么会报这个错。