bonsaidb icon indicating copy to clipboard operation
bonsaidb copied to clipboard

Add Collection Versioning (allows basic migration logic)

Open ecton opened this issue 4 years ago • 1 comments
trafficstars

We need to have a way to allow collections to upgrade themselves between versions.

  • [ ] Add an CollectionSchema trait with a version() function, like View. Also add a a function like async 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_version before 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).

ecton avatar Apr 01 '21 02:04 ecton

Oops, my brain read the wrong number when writing that commit message.

ecton avatar Mar 26 '22 22:03 ecton