-
Notifications
You must be signed in to change notification settings - Fork 0
hotfix: migration, version, tests #100
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -124,25 +124,29 @@ async def async_unload_entry( | |||||
| async def async_migrate_entry(hass: HomeAssistant, config_entry: ConfigEntry) -> bool: | ||||||
| """Migrate old config_entry to the respective version. | ||||||
|
|
||||||
| HA Standard: method will be called if manifest version does not match the config_entry version. So no need to compare versions in coding, just check for the respective version. | ||||||
| Expect downgrades! | ||||||
| Note: config_entry.version and config_entry.minor_version are the CONFIG ENTRY | ||||||
| SCHEMA version numbers. They must be explicitly set during migration to match | ||||||
| the versions defined in ConfigFlow (VERSION and MINOR_VERSION). | ||||||
|
|
||||||
| """ | ||||||
|
|
||||||
| integrated_version = config_entry.data.get(D_INTEGRATION_VERSION, "0.0.0") | ||||||
| _LOGGER.debug( | ||||||
| "Checking migration from config_entry version %s.%s", | ||||||
| config_entry.version, | ||||||
| config_entry.minor_version, | ||||||
| ) | ||||||
|
|
||||||
| # changing to v1.2.0 | ||||||
| # all versions before 1.2.0 do not have an integrated version | ||||||
| if integrated_version == "0.0.0": | ||||||
| if MINOR_VERSION == 2: | ||||||
|
||||||
| _LOGGER.info( | ||||||
| "Migrating config entry to version %s.%s.%s", | ||||||
| "Migrating config entry to integration version %s.%s.%s", | ||||||
| VERSION, | ||||||
| MINOR_VERSION, | ||||||
| PATCH_VERSION, | ||||||
| ) | ||||||
| if D_INTEGRATION_VERSION not in config_entry.data: | ||||||
| _LOGGER.info("Adding integration version to existing config entry") | ||||||
|
|
||||||
| # Update both the data AND the schema version | ||||||
| hass.config_entries.async_update_entry( | ||||||
| config_entry, | ||||||
| data={ | ||||||
|
|
@@ -190,11 +194,11 @@ async def async_migrate_entry(hass: HomeAssistant, config_entry: ConfigEntry) -> | |||||
| "Failed to remove old entity registry entries during migration" | ||||||
| ) | ||||||
|
|
||||||
| # changing to v1.2.1 | ||||||
| # changing to v1.3.0 | ||||||
| # add new base_url parameter to config entry | ||||||
| if integrated_version == "1.2.0": | ||||||
| if MINOR_VERSION == 3: | ||||||
|
||||||
| if MINOR_VERSION == 3: | |
| if config_entry.minor_version < 3: |
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.
This comment describes the correct behavior but contradicts the implementation below. The migration code should check
config_entry.versionandconfig_entry.minor_versionto determine what migrations to apply, but the actual code checks the current MINOR_VERSION constant instead.