Skip to content
This repository has been archived by the owner on Jun 18, 2019. It is now read-only.

Timestamps on entity_translations table break queries #14

Closed
franzose opened this issue Mar 23, 2014 · 2 comments
Closed

Timestamps on entity_translations table break queries #14

franzose opened this issue Mar 23, 2014 · 2 comments

Comments

@franzose
Copy link

Hi, dimsav. Your package is really great. But somehow I just have faced an issue. So, I would like to add timestamps columns to translations table to distinguish the time a certain translation was posted on. But something went wrong when I did it. $entity->translations became empty.

I have something like this:

 Schema::create('posts', function(Blueprint $table)
{
    $table->increments('id');
    $table->string('slug');

    // something else here

    $table->timestamps();
    $table->softDeletes();
});

Schema::create('post_translations', function(Blueprint $table)
{
    $table->increments('post_translation_id');
    $table->integer('post_id')->unsigned();
    $table->boolean('active')->default(0);

    // title, excerpt and content are in $translatedAttributes as they should
    $table->string('title');
    $table->text('excerpt')->default('');
    $table->longText('content');
    $table->string('locale')->index();
    $table->timestamps();
    $table->softDeletes();

    $table->unique(['post_id', 'locale']);
    $table->foreign('post_id')->references('id')->on('posts')->onDelete('cascade');
});
@dimsav
Copy link
Owner

dimsav commented Mar 23, 2014

Hi @franzose,

try to replace $table->increments('post_translation_id'); with $table->increments('id'); and give me some feedback if this solves the problem.

@franzose
Copy link
Author

@dimsav, It seems that changing the primary key name has solved the issue. Thanks!

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