Problem with migrations
fabdelgado opened this issue · 2 comments
Hello, I have a problem with a migration.
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.
That's because the data type is incompatible. teams.id is an unsigned integer (not big integer) as defined in migrations here:
https://github.com/mpociot/teamwork/blob/master/database/migrations/2016_05_18_000000_teamwork_setup_tables.php#L44
You need to use $table->integer('team_id)->unsigned()->nullable();
. This should fix it.
@okaufmann, it works
thanks!