fixed some bugs in migrations