0

I have a problem with a migration and package Teamwork (https://github.com/mpociot/teamwork)

I need an Emission to be able to have (N Teams), but when a migration is run, Laravel says

SQLSTATE [HY000]: General error: 1215 Unable to add foreign key constraint (SQL: alter table emissions add constraint emissions_team_id_foreign foreign key ( team_id) references teams (id) on delete cascade)

I don't understand if it is something from the package or what may be happening.

The order of execution is first Teamwork and then the migration of Emission.

enter image description here

user3058963
  • 105
  • 1
  • 2
  • 8
  • Searching for your error msg turns up many answers here on SO, do they help? Also, [please don't post images of code/error messages.](https://meta.stackoverflow.com/questions/285551/why-not-upload-images-of-code-on-so-when-asking-a-question/285557#285557) – Don't Panic Jul 09 '20 at 00:32
  • Does this answer your question? [SQLSTATE\[HY000\]: General error: 1215 Cannot add foreign key constraint Laravel](https://stackoverflow.com/questions/43673142/sqlstatehy000-general-error-1215-cannot-add-foreign-key-constraint-laravel) – Don't Panic Jul 09 '20 at 00:32
  • @Don'tPanic yes this is error – user3058963 Jul 09 '20 at 00:37
  • 1
    I found the problem: If the PK is a BigInteger (20) not is possible make a relation with another table wich column id is a Integer(10). – user3058963 Jul 09 '20 at 01:42
  • Great - [that solution is right there in the duplicate I linked](https://stackoverflow.com/a/55878646/6089612). This question should be closed as a duplicate. – Don't Panic Jul 10 '20 at 00:02

0 Answers0