Skip to content
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

feat: Automatic settings migration #24871

Merged
merged 7 commits into from
Nov 22, 2024
Merged

Conversation

Nerivec
Copy link
Collaborator

@Nerivec Nerivec commented Nov 22, 2024

Changes

  • Add auto versioning to configuration.yaml for successive migration support
  • Remove migrated schema keys
  • Update old tests to use new schema keys
  • Remove tests no longer needed due to migration system
  • Remove leftover legacy type in DeviceOptions
  • Fix settings.test.ts not properly mocked (from).

Migration

  • Backup existing configuration.yaml before each migration
  • Handle (in that order):
    • transfer: if path exists, remove it, and:
      • create new path with previous value
      • or if both paths already exist and are arrays, merge them
      • or if new path already has a different value, keep new path as is
    • change: change value at path if needed, and possibly if matching one of given values
    • add: add new path with given value
    • remove: remove path if exists
    • combination of above (through successive iterations on same-ish path, e.g. transfer experimental.xyz then remove experimental)
  • Create migration notes for each migration based on previous value (if a change is actually produced) in data/ directory
Example migration notes
[REMOVAL] HA discovery_topic was moved from advanced.homeassistant_discovery_topic to homeassistant.discovery_topic.

[TRANSFER] Baudrate was moved from advanced.baudrate to serial.baudrate.

[REMOVAL] RTSCTS was moved from advanced.rtscts to serial.rtscts.

[TRANSFER] ban was renamed to passlist.

[ADDITION] Migrated settings to version 2

For more details, see https://github.com/Koenkk/zigbee2mqtt/discussions/24198

Important

While this automatically migrates Z2M settings, it cannot migrate side-effects on third parties (like Home Assistant). Make sure you go over the migration notes and the link given to adjust things accordingly on that front.

@Koenkk Koenkk merged commit 5307f20 into Koenkk:feat/2.0.0 Nov 22, 2024
11 checks passed
@Koenkk
Copy link
Owner

Koenkk commented Nov 22, 2024

Very nice 🥇

@Nerivec Nerivec deleted the settings-migration branch November 22, 2024 20:46
Koenkk pushed a commit that referenced this pull request Dec 1, 2024
* feat: Automatic settings migration

* Handle failing on unsupported version.

* Handle change not needed.

* Test change not wanted.

* Cleanup.

* Add `external_converters` removal.

* Fix schema export.
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