2
良好的一天,我有两个迁移表,第一个是用于创建客户模式:Laravel 5.2 [PDOException] SQLSTATE [42000] - 创建两个AUTO_INCREMENT主键字段
Schema::create('customers', function (Blueprint $table) {
$table->increments('id');
$table->string('first_name',45);
$table->string('middle_name',45)->nullable();
$table->string('last_name',45);
$table->string('gender',45);
$table->string('dob',45);
$table->string('martial_status',45);
$table->string('home_phone',12)->nullable();
$table->string('mobile_phone',12);
$table->string('work_phone',12);
$table->string('id_number',12);
$table->string('id_type',45);
$table->string('id_exp',20);
$table->date('id_issue_date');
$table->text('id_image')->nullable();
$table->timestamps();
第二个是用于创建customer_address模式:
Schema::create('customers_address', function (Blueprint $table) {
$table->increments('id');
$table->integer('customer_id')->unsigned();
$table->foreign('customer_id')->references('id')->on('customers')->onDelete('cascade');
$table->string('address_line1',20);
$table->string('address_line2',20)->nullable();
$table->string('ownership',20);
$table->string('country');
$table->string('town_city');
$table->string('parish_state');
$table->integer('years_at_address',10);
$table->timestamps();
});
运行PHP工匠迁移时
,我得到了我的终端一个错误,说[PDOException] SQLSTATE [42000]:语法错误或访问冲突:1075不正确的表定义;只能有一个自动列,并且必须将其定义为键。
什么可能导致我得到这个,因为我没有看到我在这里做错了什么。在此先感谢您的帮助。
谢谢,不敢相信我没有看到。 – newbieDev