1
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

DevTools failed to load SourceMap: Could not load content for http://127.0.0.1:8080/js/popper.js.map: HTTP error: status code 404, net::ERR_HTTP_RESPONSE_CODE_FAILURE の解決例

Last updated at Posted at 2020-05-07

原因

  • モデルの指定し忘れ
  • 外部キーカラムの設定のミス

解決方法

laravel5.8を使っている場合なのですが、postsのマイグレーションに外部キーを追加する所の

database/migrations/2017_05_22_041557_create_posts_table.php $table->integer('user_id')->unsigned()->default(1);

ここの部分ですが、

$table->bigInteger('user_id')->unsigned()->default(1);

のようにすることで動きました。

※2024/12/02追記

laravel11なら外部キーのカラムは

$table->foreignId('user_id');

の様によりスマートに書けるので、こちらの書き方をお勧めします。

参考

Laravel 5.8 にて["SQLSTATE[HY000]: General error: 1215 Cannot add foreign key constraint"]エラー

1
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?