optimize timestamp migration script