Skip to content

Commit

Permalink
Chore: Cleanup migrations of schemas
Browse files Browse the repository at this point in the history
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 <tykeal@bardicgrove.org>
  • Loading branch information
tykeal committed Jun 15, 2024
1 parent 99a983a commit cdd41d6
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions custom_components/rental_control/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand All @@ -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)

Expand All @@ -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)

Expand All @@ -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")

Expand All @@ -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")

Expand Down

0 comments on commit cdd41d6

Please sign in to comment.