Skip to content
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
@sdebacker

Description

@sdebacker

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

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions