Composite key in laravel migrate

2

I would like to create a double primary key with an auto increment field "id" and "id_lement_time", but it gives error and I do not know the correct way to do it, if someone can help me, I would appreciate it! >

Migrate

Schema::create('disciplinas', function (Blueprint $table) {
        $table->increments('id');
        $table->integer('periodo_letivos_id')->unsigned();
        $table->foreign('periodo_letivos_id')
            ->references('id')
            ->on('periodo_letivos')
            ->onDelete('cascade');
        $table->integer('cursos_id')->unsigned();
        $table->foreign('cursos_id')
            ->references('id')
            ->on('cursos')
            ->onDelete('cascade');
        $table->integer('periodo_regular')->nullable();
        $table->string('matriz_curricular')->nullable();
        $table->string('nome', 200);
        $table->string('abrev_nome', 15);
        $table->integer('professors_id')->unsigned();
        $table->foreign('professors_id')
            ->references('id')
            ->on('professors')
            ->onDelete('cascade');
        $table->string('aulas', 3)->nullable();
        $table->string('aulas_hora', 3)->nullable();
        $table->string('obs', 400)->nullable();
        $table->primary(['id', 'periodo_letivos_id']);
        $table->timestamps();
        $table->softDeletes();
    });
    
asked by anonymous 18.05.2018 / 00:44

0 answers