Fixed #651: Hooks: pre-migration and post-migration