added migration logic for old to new db