When i try to add foreign keys to my migrations the method 'foreign' is not known, when i try to run the migration i get an error saying something about a syntax error. i can't find what needs to be done.
SQLSTATE[42000]: Syntax error or access violation: 1064 You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near ')' at line 1 (SQL: alter table
requestsadd constraintrequests_family_id_foreignforeign key (family_id) referencesid())
this is my migration code
<?php
use Illuminate\Database\Migrations\Migration;
class TableFamilymembersKeys extends Migration
{
public function up()
{
Schema::table('requests', function ($table) {
$table->foreign('family_id')->reference('families')->on('id');
});
}
public function down()
{
}
}
does anyone know how to fix this or did someone encountered this problem before?
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire