reorder schemas to account for foreign keys