bonsaidb
bonsaidb copied to clipboard
Add Collection Versioning (allows basic migration logic)
trafficstars
We need to have a way to allow collections to upgrade themselves between versions.
- [ ] Add an
CollectionSchematrait with aversion()function, likeView. Also add a a function likeasync fn upgrade_from_previous_version<C: Connection>(connection: &C, stored_version: u64). Maybe blocked by #113. - [ ] Store a mapping of all known schema names and their versions when creating a database.
- [ ] Upon opening an existing database, check the list of schemas against the ones stored. If any versions don't match, call
upgrade_from_previous_versionbefore allowing any operations on that collection. - [ ] A list of all views should be stored for each collection.
- [ ] If a collection or view is missing after upgrade, the files should be removed.
- This sounds dangerous, but having data that must be cleaned up manually is also bad. Maybe there should be a setting that prevents this behavior for Collections? Views are ephemeral so this is fine for views no matter what.
- [ ] Schema should have a callback that is invoked when any set of collections are upgraded (with the list of upgraded collections).
Oops, my brain read the wrong number when writing that commit message.