Rank 2: Process
As my production app evolves, I make changes to the structure of the collections that are used. Some of the structure changes require a 'migration' of the existing documents so that they match the new structure. To manage this, I have written a tool that I run after each structure change (if required) that does the heavy lifting, but it's a fairly brute-force approach: as the number of structure changes grows, so does the number of 'migrations'.
In an ideal world I would like to know which iteration of the structure a collection is currently at, and only apply the necessary migrations applicable to that iteration. In other words, I would like to 'version' a collection and then say something like "If the collection is less than this version, then do this migration."
Has anyone solved a similar problem? Any thoughts about how I might go about doing this?