This repository was archived by the owner on Jun 18, 2019. It is now read-only.
This repository was archived by the owner on Jun 18, 2019. It is now read-only.
When deleting a translated model where child have a FK Restrict, model is not deleted but translations are deleted #7
Closed
Description
According to the schema below, if I delete a menu, the DB stop the deletion because of the FK in menulinks but menu_translations are deleted. It's because laravel-translatable delete translations first.
Why not let the DB delete translations by setting ->onDelete('cascade');
on the FK ?
Here is the schema :
Schema::create('menus', function(Blueprint $table)
{
$table->increments('id')->unsigned();
$table->string('name');
});
Schema::create('menu_translations', function(Blueprint $table)
{
$table->increments('id')->unsigned();
$table->integer('menu_id')->unsigned();
$table->string('locale')->index();
$table->string('title');
$table->unique(array('menu_id', 'locale'));
$table->foreign('menu_id')->references('id')->on('menus');
});
Schema::create('menulinks', function(Blueprint $table)
{
$table->increments('id')->unsigned();
$table->integer('menu_id')->unsigned();
$table->foreign('menu_id')->references('id')->on('menus');
});
Schema::create('menulink_translations', function(Blueprint $table)
{
$table->increments('id')->unsigned();
$table->integer('menulink_id')->unsigned();
$table->string('locale')->index();
$table->string('title');
$table->unique(array('menulink_id', 'locale'));
$table->foreign('menulink_id')->references('id')->on('menulinks');
});
Metadata
Metadata
Assignees
Labels
No labels