time calculation in api, improved migrations