Fix bug in database migration