Fixed migration errors
Improvements to 038 migration (issue history rebuild).

- using bulk inserts
- removed excessive selects
- using eager assosiations load to minimize query count
Merged branch v32_migration_performance to master