mercredi 21 septembre 2016

Syntax error or access violation: 1072 Key column - self-join

I would like to have a custom name for my foreign key. how can I do ? I'm using below code but it get me error :

SQLSTATE[42000]: Syntax error or access violation: 1072 Key column 'parent_section_id' doesn't exist in table (SQL: alter table sections add constraint sections_parent_section_id _foreign foreign key (parent_section_id) references sections (id) on delete cascade)

public function up()
{
    Schema::create('sections', function (Blueprint $table) {
        $table->increments('id');
        $table->string('title');
        $table->foreign('parent_section_id')->references('id')->on('sections')->onDelete('cascade');
        $table->timestamps();
    });
}



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire