Fix foreign keys in sqlite migrations, refs #474.