【发布时间】:2021-11-03 20:05:41
【问题描述】:
我有这两个迁移
tb_store
Schema::create('tb_store', function (Blueprint $table) {
$table->integer('cnpj')->unsigned();
$table->string('email', 255);
$table->string('password', 255);
$table->string('corporateName', 255);
$table->primary(['cnpj', 'email']);
$table->timestamps();
$table->softDeletes();
});
tb_store_address
Schema::create('tb_store_address', function (Blueprint $table) {
$table->string('email', 255);
$table->foreign('email')->references('email')->on('tb_store')->cascadeOnDelete();
$table->integer('cnpj')->unsigned();
$table->foreign('cnpj')->references('cnpj')->on('tb_store')->cascadeOnDelete();
$table->primary(['cnpj', 'email']);
$table->string('address', 255);
$table->integer('number')->unsigned();
$table->integer('phone')->unsigned();
$table->integer('postalCode')->unsigned();
$table->string('neighborhood', 255);
$table->string('complement', 255)->nullable();
$table->integer('idCity')->unsigned();
$table->foreign('idCity')->references('idCity')->on('tb_city')->cascadeOnDelete();
});
运行时出现以下错误
【问题讨论】:
-
该错误清楚地表明缺少索引。因此,您必须为提到的列设置索引。
-
@B001 我该怎么做?
标签: php laravel eloquent migration