LoginSignup
0
0

More than 1 year has passed since last update.

[mysql]Cannot add or update a child row: a foreign key constraint fails ~ の解決例

Last updated at Posted at 2021-10-10

何をしたら出た?

ローカルでeditアクションを編集したので、動作確認のためにdevelop環境のrequestのpayload(edit後の値として送るデータ)をgoogleのデベロッパーツールで取得して、postmanを使ってlocal環境で同じものをpaylodにして送ったところ出現

原因は?

develop環境とlocal環境のDB内のレコードに差分があり、本来外部キー制約で存在している前提としていた子テーブルのレコードがなくなっていた。

解決方法

子テーブルのレコードをlocalにも追加してから、再度postmanを使ってlocal環境で同じものをpaylodにして送ることでエラーを解決できた。

0
0
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
0
0