Skip to content
This repository has been 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 opened this issue Feb 27, 2014 · 4 comments

Comments

@sdebacker
Copy link
Collaborator

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');
});
@dimsav
Copy link
Owner

dimsav commented Mar 6, 2014

Unfortunately I didn't find the time yet to deal with this. Is it possible for you to create a pull request with the failing test?

I agree that translations should be deleted by the database.

dimsav added a commit that referenced this issue Mar 8, 2014
dimsav added a commit that referenced this issue Mar 8, 2014
@dimsav
Copy link
Owner

dimsav commented Mar 8, 2014

Thanks for the pull request :) I think I will update the repository tag to 3, because with the new commit the package is not 100% backwards compatible with the version 2. It would be nice to hear your opinion though.

@sdebacker
Copy link
Collaborator Author

I think it´s a good idea.
Laravel translatable stay for me one of the most useful package I use.

Samuel

Le 8 mars 2014 à 21:03, Dimitrios Savvopoulos notifications@github.com a écrit :

Thanks for the pull request :) I think I will update the repository tag to 3, because with the new commit the package is not 100% backwards compatible with the version 2. It would be nice to hear your opinion though.


Reply to this email directly or view it on GitHub.

@dimsav
Copy link
Owner

dimsav commented Mar 9, 2014

Glad to hear that. Alright I will apply the v3 tag to the repository. Thanks for the help.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants