Support non-live database migration (#72433)
* Support non-live database migration * Tweak startup order, add test * Address review comments * Fix typo * Clarify comment about promoting dependencies * Tweak * Fix merge mistake * Fix some tests * Fix additional test * Fix additional test * Adjust tests * Improve test coverage
This commit is contained in:
@@ -552,7 +552,7 @@ def write_lock_db_sqlite(instance: Recorder) -> Generator[None, None, None]:
|
||||
|
||||
|
||||
def async_migration_in_progress(hass: HomeAssistant) -> bool:
|
||||
"""Determine is a migration is in progress.
|
||||
"""Determine if a migration is in progress.
|
||||
|
||||
This is a thin wrapper that allows us to change
|
||||
out the implementation later.
|
||||
@@ -563,6 +563,18 @@ def async_migration_in_progress(hass: HomeAssistant) -> bool:
|
||||
return instance.migration_in_progress
|
||||
|
||||
|
||||
def async_migration_is_live(hass: HomeAssistant) -> bool:
|
||||
"""Determine if a migration is live.
|
||||
|
||||
This is a thin wrapper that allows us to change
|
||||
out the implementation later.
|
||||
"""
|
||||
if DATA_INSTANCE not in hass.data:
|
||||
return False
|
||||
instance: Recorder = hass.data[DATA_INSTANCE]
|
||||
return instance.migration_is_live
|
||||
|
||||
|
||||
def second_sunday(year: int, month: int) -> date:
|
||||
"""Return the datetime.date for the second sunday of a month."""
|
||||
second = date(year, month, FIRST_POSSIBLE_SUNDAY)
|
||||
|
||||
Reference in New Issue
Block a user