-
Notifications
You must be signed in to change notification settings - Fork 186
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Remove dexie version bump requirement for new game additions #1373
Remove dexie version bump requirement for new game additions #1373
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I know this is a bit late on the second review round, but did you consider using Version.upgrade to do all this in one fell swoop, thus not requiring run-time checkups?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Overall looks okay and I tested this locally so works on my PC. Left a few nitpick/opinion comments in case the Version.upgrade()
approach doesn't pan out.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For me this doesn't work as expected, see the comments. I guess valid approaches would be:
- Fix this one way or another to actually persist existing settings upon migration
- Clean out the ineffective data migration code, effectively just resetting the game specific settings
- Fall back using the older approach which didn't use
Version.upgrade()
87df8bc
to
49e9b84
Compare
This commit primarily implements a way to track settings without requiring each game to exist as an independent table. This is done by, simply, moving everything to a new `games` table, by which each game is a row, indexable by each's setting identifier. This commit also removes code that migrated the legacy settings store to v2, but don't fret, I've replaced it with migration code that converts v2 game tables to the new v3 row entries. feat: add legacy table clear, remove old migration code chore: resolve PR review comments - Replace occurences of `==` with customary `===`. - Remove transaction wrapper from `applyV2ToV3Migration` - Invert logic of `getLatestGameSpecific` to reduce nesting and catch case where `game === undefined` and `applyV2ToV3Migration === true`. feat: move migration code to `Version.upgrade` This should ideally handle the migration from < 75 versions to 75 automatically at runtime, thus removing the need to integrate the migration routine into `getLatestGameSpecific`. Legacy game tables are not entirely removed, but they are cleared and, thanks to `Version.upgrade`, should not cause any future problems. chore: code cleanup - remove trailing whitespace, imports, debug log
49e9b84
to
ffa61c8
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
Tested locally and works for me:
- Migrating to the new schema and persisting the existing settings
- Creating a new settings row when a game is accessed for the first time
- Adding new games does not require a schema version bump
const identifier = this.activeGame.settingsIdentifier; | ||
const game = await this.games.get(identifier); | ||
|
||
if (game !== undefined) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nitpick: NGL I'm a tiny bit irked that the gameSpecific checks !== undefined
while the corresponding code for global settings checks === undefined
🙈
This PR primarily implements a way to track settings without requiring each game to exist as an independent table. This is done by, simply, moving everything to a new
games
table, by which each game is a row, indexable by setting identifier.This also removes code that migrated the legacy settings store to v2, but don't fret, I've replaced it with migration code that converts v2 game tables to the new v3 row entries.