Migration files should be created in such a way that the parent migration should come first and the migration file with the foreign key next.
The foreign key and the primary id in the other table should have exactly similar property. If the primary id is increments then make the foreign key integer('xxx_id')->unsigned();