move collection and item migration functions from script to main codebase so we can use them from app

item.py and collection.py are now, temporarily, even messier than they were.
but code reuse ftw, and will continue refactoring to clean.
handle starting at an arbitrary startkey