afes-website / back

73rd Afes Official Website back-end
https://api.73.afes.info
MIT License
3 stars 0 forks source link

foreign keyの重複を許してない? #150

Closed Takeno-hito closed 3 years ago

Takeno-hito commented 3 years ago
In Connection.php line 669:

  SQLSTATE[HY000]: General error: 1826 Duplicate foreign key constraint name   
  'articles_revision_id_foreign' (SQL: alter table `articles` add constraint   
  `articles_revision_id_foreign` foreign key (`revision_id`) references `revi  
  sions` (`id`) on delete restrict on update restrict)                         

In PDOStatement.php line 129:

  SQLSTATE[HY000]: General error: 1826 Duplicate foreign key constraint name   
  'articles_revision_id_foreign'                                               

In PDOStatement.php line 127:

  SQLSTATE[HY000]: General error: 1826 Duplicate foreign key constraint name   
  'articles_revision_id_foreign'                                               

そういえばと思ってmigrationを叩いたら おそらくrevisionIdとArticleIdが1-1の関係であるとは限らないからという理由に見えます、があまり外部キー制約の使い方を知らないので調べて対処する(知らないのにレビューしてごめんなさい、、)

Takeno-hito commented 3 years ago

読み間違い+おま環でした (何故かdraftTableのidがBigIntになっててそこで詰まってた) 制約付けに失敗する事がある(DBの中身が正しくない)かもしれないので、それの対応は書いてもいいのかなと少し思った、僕はやりません