mirror of
https://github.com/home-assistant/core.git
synced 2025-07-30 02:38:10 +02:00
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:
@ -1,7 +1,8 @@
|
||||
"""Helpers to check recorder."""
|
||||
|
||||
import asyncio
|
||||
|
||||
from homeassistant.core import HomeAssistant
|
||||
from homeassistant.core import HomeAssistant, callback
|
||||
|
||||
|
||||
def async_migration_in_progress(hass: HomeAssistant) -> bool:
|
||||
@ -12,3 +13,26 @@ def async_migration_in_progress(hass: HomeAssistant) -> bool:
|
||||
from homeassistant.components import recorder
|
||||
|
||||
return recorder.util.async_migration_in_progress(hass)
|
||||
|
||||
|
||||
@callback
|
||||
def async_initialize_recorder(hass: HomeAssistant) -> None:
|
||||
"""Initialize recorder data."""
|
||||
# pylint: disable-next=import-outside-toplevel
|
||||
from homeassistant.components.recorder import const, models
|
||||
|
||||
hass.data[const.DOMAIN] = models.RecorderData()
|
||||
|
||||
|
||||
async def async_wait_recorder(hass: HomeAssistant) -> bool:
|
||||
"""Wait for recorder to initialize and return connection status.
|
||||
|
||||
Returns False immediately if the recorder is not enabled.
|
||||
"""
|
||||
# pylint: disable-next=import-outside-toplevel
|
||||
from homeassistant.components.recorder import const
|
||||
|
||||
if const.DOMAIN not in hass.data:
|
||||
return False
|
||||
db_connected: asyncio.Future[bool] = hass.data[const.DOMAIN].db_connected
|
||||
return await db_connected
|
||||
|
Reference in New Issue
Block a user