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
from Newest questions tagged laravel-5 - Stack Overflow http://ift.tt/2dr2fZg
via IFTTT
Aucun commentaire:
Enregistrer un commentaire