我有這兩個遷移
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();
});
當我運行時出現以下錯誤 
uj5u.com熱心網友回復:
https://laravel.com/docs/8.x/migrations#creating-indexes
最簡單的方法是鏈接獨特的功能。
Schema::create('tb_store', function (Blueprint $table) {
$table->integer('cnpj')->unsigned()->unique();
$table->string('email', 255)->unique();
$table->string('password', 255);
$table->string('corporateName', 255);
$table->primary(['cnpj', 'email']);
$table->timestamps();
$table->softDeletes();
});
轉載請註明出處,本文鏈接:https://www.uj5u.com/net/349335.html
上一篇:Laravel雄辯與條件
