Fix foreign key handling in sqlite migrations. Fixes #380