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 |
다시 마이그레이션 실행한다.
'라라벨 > Migration' 카테고리의 다른 글
unsignedInteger(음수를 사용지않음) (0) | 2020.03.29 |
---|---|
마이그레이션 에러 (0) | 2020.01.18 |
컬럼삭제하기 (0) | 2020.01.01 |