dimanche 12 février 2017

Cannot add foreign key constraint in laravel error

I have a migration for my tags table like the below:

Schema::create('tags', function (Blueprint $table) {
            $table->increments('id');
            $table->char('tag' , 15);
});

Now, I have the following migration for my admin table in which i have a foreign key associated with my tags table , the migration is the following:

Schema::create('admin', function (Blueprint $table) {
    $table->char('tag' , 15);
    $table->foreign('tag')->references('tag')->on('tags');
});

Now when i run this migration i get the following error:

enter image description here

Both the tables are innodb i have changed this in the settings in laravel. But i still get a cannot add a foreign key constraint error. Why ??



from Newest questions tagged laravel-5 - Stack Overflow http://ift.tt/2lF4rjR
via IFTTT

Aucun commentaire:

Enregistrer un commentaire