Skip to content

Default migrationStep to latest so fresh installs skip migrations#631

Merged
marionbarker merged 1 commit intodevfrom
migration-step-default-latest
May 4, 2026
Merged

Default migrationStep to latest so fresh installs skip migrations#631
marionbarker merged 1 commit intodevfrom
migration-step-default-latest

Conversation

@bjorkert
Copy link
Copy Markdown
Member

@bjorkert bjorkert commented May 1, 2026

Summary

Previously migrationStep defaulted to 0, forcing every fresh install to iterate through every migration step. The migrations are designed for upgraders carrying legacy state — for a brand-new install they're all no-ops or set values that the static defaults could just hold directly.

This change sets the default migrationStep to the current latest step (7) and updates the other StorageValue defaults so a fresh install ends up in the same state as a user who ran every migration:

  • snoozerPosition: .menu.position3
  • nightscoutPosition: .position3.position4
  • remotePosition: .position4.menu
  • hasSeenFatProteinOrderChange: falsetrue (matches what step 4 sets for fresh installs via !isExistingUser)

alarmsPosition (.position2) and homePosition (.position1) already matched the post-migration state.

Reminder comments are added at the migrationStep declaration and at the runMigrationsIfNeeded() block so future authors remember to bump the default and update affected defaults whenever a new migration step is added.

Existing users are unaffected: they have a stored migrationStep value and continue to run only the steps they haven't yet executed.

Previously migrationStep defaulted to 0, forcing every fresh install to
iterate through every migration. Set the default to the latest step (7)
and update other StorageValue defaults to match the post-migration final
state on a fresh install:

- snoozerPosition: .menu -> .position3
- nightscoutPosition: .position3 -> .position4
- remotePosition: .position4 -> .menu
- hasSeenFatProteinOrderChange: false -> true

Add reminder comments at the migrationStep declaration and at the
runMigrationsIfNeeded() block so future authors bump the default and
update affected defaults whenever a new step is added.
@bjorkert bjorkert requested a review from codebymini May 1, 2026 20:48
Copy link
Copy Markdown
Collaborator

@marionbarker marionbarker left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approve from code review and test build.

@marionbarker marionbarker merged commit 2fa57b2 into dev May 4, 2026
1 check passed
@marionbarker marionbarker deleted the migration-step-default-latest branch May 4, 2026 03:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants