SQLSTATE[HY000]: General error: 1005 Can't create table.`payments`
(errno: 150 "Foreign key constraint is incorrectly formed")
(SQL: alter table payments add constraint payments_customer_id_foreign foreign key (customer_id) references costumer_details (id) on delete cascade)
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
class CreatePaymentsTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('payments', function (Blueprint $table) {
$table->id();
$table->float('total');
$table->text('payment_type');
$table->string('status')->default('active');
$table->unsignedBigInteger('customer_id');
$table->foreign('customer_id')->references('id')->on('costumer_details')->onDelete('cascade');
$table->timestamps();
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::dropIfExists('payments');
}
}
Aucun commentaire:
Enregistrer un commentaire