I am using Laravel 5.3 and MySQL.
How can I add in laravel foreign keys references to a primary key with two columns?
I have something like
primary key with two columns
public function up()
{
Schema::create('X', function (Blueprint $table) {
$table->integer('a')->unsigned();
$table->integer('b')->unsigned();
$table->primary(['a', 'b']);
$table->timestamps();
});
}
and in another
public function up()
{
Schema::create('Y', function (Blueprint $table) {
$table->increments('k');
$table->foreign('c')->references(['a', 'b'])->on('X')->onDelete('cascade');
$table->timestamps();
});
}
However, it doesn't work so what should I put?
Any help would be really appreciated, Thanks in advance
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire