fixed bugs in migration script and added post-migration scripts