fix dirty flag and update/store statistics after migration, fixes #1735, fixes #1761
convert logs to assertions
Merge pull request #1768 from eminn/maintenance-2.x

Set dirty flag and update/store statistics after migration