Rarity
Rarity copied to clipboard
Add a way to seamlessly migrate the database schema
Goals:
- [ ] I want to be able to change the database schema without breaking settings stored in the
SavedVariables - [ ] The existing functionality to remove obsolete items (some Nazjatar toys that never made it to live) should be integrated
- [ ] Validating against the schema should be trivial to make sure future refactoring isn't impeded by a need for backwards-compatibility
- [ ] Particular care must be taken to not break custom (user-defined) items and settings, so we need some unit tests for this
The Migrations feature in Django is probably a decent source of inspiration, even if we don't have a proper database (it's just a Lua table) and the operations performed are simpler.
Roadmap:
- [ ] Each iteration of the database is identified by an index (unique ID, starting at 1)
- [ ] Database schema changes are stored as diffs to the previous version
- [ ] The current version is also stored, and can be used to automatically apply migrations on startup (careful here)
- [ ] Migrations can be performed manually, with a
/rarity migrateslash command (to aid in debugging) - [ ] The current (`as stored in the user's
SavedVariables) schema version should be displayed somewhere in the options - [ ] The latest (as stored in the
Rarity.DatabaseSchema.versionfield) version should also be displayed - [ ] With these two, we can display a warning/notice that the schema needs upgrading (while debugging. Later it should happen automatically)
- [ ] When automatic migrations are performed, a message should be displayed in the chat window (in case it takes a while)
- [ ] A backup of the database should probably be created. Perhaps optionally if it's very large?
Rest TBD