마이그레이션에러 SQLSTATE[HY000]: General error: 3780

마이그레이션에러 SQLSTATE[HY000]: General error: 3780

Illuminate\Database\QueryException : SQLSTATE[HY000]: General error: 3780 Referencing column 'user_id' and referenced column 'id' in foreign key constraint 'questions_user_id_foreign' are incompatible. (SQL: alter table `questions` add constraint `questions_user_id_foreign` foreign key (`user_id`) references `users` (`id`) on delete cascade on update cascade)

at /Users/wonhochoi/laravel-qa/vendor/laravel/framework/src/Illuminate/Database/Connection.php:669

665| // If an exception occurs when attempting to run a query, we'll format the error

666| // message to include the bindings with SQL, which will make this exception a

667| // lot more helpful to the developer instead of just the database's errors.

668| catch (Exception $e) {

> 669| throw new QueryException(

670| $query, $this->prepareBindings($bindings), $e

671| );

672| }

673|

Exception trace:

1 PDOException::("SQLSTATE[HY000]: General error: 3780 Referencing column 'user_id' and referenced column 'id' in foreign key constraint 'questions_user_id_foreign' are incompatible.")

/Users/wonhochoi/laravel-qa/vendor/laravel/framework/src/Illuminate/Database/Connection.php:463

2 PDOStatement::execute()

/Users/wonhochoi/laravel-qa/vendor/laravel/framework/src/Illuminate/Database/Connection.php:463

Please use the argument -v to see more details.

1 $table->unsignedInteger('user_id'); cs

수정

1 $table->unsignedBigInteger('user_id'); cs

다시 마이그레이션 실행한다.

https://qiita.com/yoshinyan/items/1f96eec326b9e5b863c4

from http://anko3899.tistory.com/330 by ccl(A) rewrite - 2021-10-28 01:27:10