Might sound like a silly question, but which record are you deleting?
Jan 16, 2020
11
Level 1
Why my Laravel on delete cascade is not working?
Why my Laravel "on cascade delete" is not working? Could you help me?
Schema::create('transactions', function (Blueprint $table) {
...
$table->unsignedBigInteger('payment_id');
$table->foreign('payment_id')->references('id')->on('payments')->onDelete('cascade');
});
Schema::create('payments', function (Blueprint $table) {
$table->bigIncrements('id');
...
});
My engine is InnoDB. 10.4.8-MariaDB, Laravel 6. php mysql laravel
Level 122
Then your keys are wrong. If revenue belongs to transaction then it should have a transaction_id column. Same for revenue. Not the other way around
The belonging to item always has the pointer to the other table
1 like
Please or to participate in this conversation.