Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PHP

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().
 
PREVIOUS NEXT
Tagged: #General #Cannot #add #foreign #key #constraint #laravel
ADD COMMENT
Topic
Name
3+3 =