Correct off-by-one bug in recorder non live schema migration (#122428)

* Correct off-by-one bug in recorder non live schema migration

* Remove change from the future
This commit is contained in:
Erik Montnemery 2024-07-23 00:30:31 +02:00 committed by GitHub
parent d0ba5534cd
commit 96de0a4c94
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 10 additions and 1 deletions

View file

@ -304,7 +304,7 @@ def migrate_schema_non_live(
schema_status: SchemaValidationStatus, schema_status: SchemaValidationStatus,
) -> SchemaValidationStatus: ) -> SchemaValidationStatus:
"""Check if the schema needs to be upgraded.""" """Check if the schema needs to be upgraded."""
end_version = LIVE_MIGRATION_MIN_SCHEMA_VERSION - 1 end_version = LIVE_MIGRATION_MIN_SCHEMA_VERSION
return _migrate_schema( return _migrate_schema(
instance, hass, engine, session_maker, schema_status, end_version instance, hass, engine, session_maker, schema_status, end_version
) )

View file

@ -71,6 +71,10 @@ async def test_schema_update_calls(
"homeassistant.components.recorder.migration._apply_update", "homeassistant.components.recorder.migration._apply_update",
wraps=migration._apply_update, wraps=migration._apply_update,
) as update, ) as update,
patch(
"homeassistant.components.recorder.migration._migrate_schema",
wraps=migration._migrate_schema,
) as migrate_schema,
): ):
await async_setup_recorder_instance(hass) await async_setup_recorder_instance(hass)
await async_wait_recording_done(hass) await async_wait_recording_done(hass)
@ -85,6 +89,11 @@ async def test_schema_update_calls(
for version in range(db_schema.SCHEMA_VERSION) for version in range(db_schema.SCHEMA_VERSION)
] ]
) )
migrate_schema.assert_has_calls(
[
call(instance, hass, engine, session_maker, ANY, db_schema.SCHEMA_VERSION),
]
)
async def test_migration_in_progress( async def test_migration_in_progress(