core icon indicating copy to clipboard operation
core copied to clipboard

Problems with the database

Open pallejs opened this issue 4 years ago • 1 comments

running the php artisan chatter:install shout out the following error:

In Connection.php line 671:
SQLSTATE[HY000]: General error: 1215 Cannot add foreign key constraint (SQL: alter table chatter_d iscussions add constraint chatter_discussions_user_id_foreign foreign key (user_id) references
users (id) on delete cascade on update cascade)

In PDOStatement.php line 129:
SQLSTATE[HY000]: General error: 1215 Cannot add foreign key constraint

In PDOStatement.php line 127: SQLSTATE[HY000]: General error: 1215 Cannot add foreign key constraint

pallejs avatar Nov 02 '20 18:11 pallejs

Solution

You need to change the migrations, in my case my users table "id" is not a Big integer.

So, you need to change the chatter migrations "user_id":

$table->unsignedBigInteger('user_id');

to

$table->unsignedInteger('user_id');

magarrent avatar May 14 '21 08:05 magarrent