From cdd41d66d9b97a3d71a0c21bb281064aaab033a9 Mon Sep 17 00:00:00 2001 From: Andrew Grimberg Date: Sat, 15 Jun 2024 13:14:27 -0700 Subject: [PATCH] Chore: Cleanup migrations of schemas Schema versions were not being properly updated during migrations. Use the correct call to update the version as the migrations are stepped through. Signed-off-by: Andrew Grimberg --- custom_components/rental_control/__init__.py | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/custom_components/rental_control/__init__.py b/custom_components/rental_control/__init__.py index 6f48627..0c9ef59 100644 --- a/custom_components/rental_control/__init__.py +++ b/custom_components/rental_control/__init__.py @@ -201,8 +201,8 @@ async def async_migrate_entry(hass: HomeAssistant, config_entry: ConfigEntry) -> entry=config_entry, unique_id=gen_uuid(data[CONF_CREATION_DATETIME]), data=data, + version=2, ) - config_entry.version = 2 version = 2 _LOGGER.debug("Migration to version %s complete", config_entry.version) @@ -220,9 +220,9 @@ async def async_migrate_entry(hass: HomeAssistant, config_entry: ConfigEntry) -> entry=config_entry, unique_id=config_entry.unique_id, data=data, + version=3, ) - config_entry.version = 3 version = 3 _LOGGER.debug("Migration to version %s complete", config_entry.version) @@ -236,9 +236,9 @@ async def async_migrate_entry(hass: HomeAssistant, config_entry: ConfigEntry) -> entry=config_entry, unique_id=config_entry.unique_id, data=data, + version=4, ) - config_entry.version = 4 version = 4 _LOGGER.debug("Migration to version %s complete", config_entry.version) @@ -252,9 +252,9 @@ async def async_migrate_entry(hass: HomeAssistant, config_entry: ConfigEntry) -> entry=config_entry, unique_id=config_entry.unique_id, data=data, + version=5, ) - config_entry.version = 5 version = 5 _LOGGER.debug(f"Migration to version {config_entry.version} complete") @@ -265,10 +265,12 @@ async def async_migrate_entry(hass: HomeAssistant, config_entry: ConfigEntry) -> data = config_entry.data.copy() data.pop(CONF_PATH, None) hass.config_entries.async_update_entry( - entry=config_entry, unique_id=config_entry.unique_id, data=data + entry=config_entry, + unique_id=config_entry.unique_id, + data=data, + version=6, ) - config_entry.version = 6 version = 6 _LOGGER.debug(f"Migration to version {config_entry.version} complete")