Answers for "artisan general error: 1215 cannot add foreign key constraint"

PHP
0

General error: 1215 Cannot add foreign key constraint laravel

Laravel 5.8 Added bigIncrements As Defaults

So there is mismatch in foreign key field types. You see bigIncrements(id) in 
User table and unsigned Integer(user_id) in questions table.

How to fix:

1. Either change original migration from bigIncrements() to just
increments()

2. Or in your foreign key column do unsignedBigInteger() instead of 
unsignedInteger().
Posted by: Guest on March-24-2021
0

error code 1215 cannot add foreign key constraint

Try this if are data in one or more tables from foreign key references
set foreign_key_checks=0;

Else it is a problem in forign key parameters (references parameters)
Posted by: Guest on January-29-2021

Code answers related to "artisan general error: 1215 cannot add foreign key constraint"

Browse Popular Code Answers by Language