mirror of
https://github.com/home-assistant/core.git
synced 2025-12-24 21:06:19 +00:00
Deduplicate event_types in the events table (#89465)
* Deduplicate event_types in the events table
* Deduplicate event_types in the events table
* more fixes
* adjust
* adjust
* fix product
* fix tests
* adjust
* migrate
* migrate
* migrate
* more test fixes
* more test fixes
* fix
* migration test
* adjust
* speed up
* fix index
* fix more tests
* handle db failure
* preload
* tweak
* adjust
* fix stale docs strings, remove dead code
* refactor
* fix slow tests
* coverage
* self join to resolve query performance
* fix typo
* no need for quiet
* no need to drop index already dropped
* remove index that will never be used
* drop index sooner as we no longer use it
* Revert "remove index that will never be used"
This reverts commit 461aad2c52.
* typo
This commit is contained in:
@@ -1148,6 +1148,16 @@ def enable_migrate_context_ids() -> bool:
|
||||
return False
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def enable_migrate_event_type_ids() -> bool:
|
||||
"""Fixture to control enabling of recorder's event type id migration.
|
||||
|
||||
To enable context id migration, tests can be marked with:
|
||||
@pytest.mark.parametrize("enable_migrate_event_type_ids", [True])
|
||||
"""
|
||||
return False
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def recorder_config() -> dict[str, Any] | None:
|
||||
"""Fixture to override recorder config.
|
||||
@@ -1291,6 +1301,7 @@ async def async_setup_recorder_instance(
|
||||
enable_statistics: bool,
|
||||
enable_statistics_table_validation: bool,
|
||||
enable_migrate_context_ids: bool,
|
||||
enable_migrate_event_type_ids: bool,
|
||||
) -> AsyncGenerator[RecorderInstanceGenerator, None]:
|
||||
"""Yield callable to setup recorder instance."""
|
||||
# pylint: disable-next=import-outside-toplevel
|
||||
@@ -1309,6 +1320,11 @@ async def async_setup_recorder_instance(
|
||||
migrate_context_ids = (
|
||||
recorder.Recorder._migrate_context_ids if enable_migrate_context_ids else None
|
||||
)
|
||||
migrate_event_type_ids = (
|
||||
recorder.Recorder._migrate_event_type_ids
|
||||
if enable_migrate_event_type_ids
|
||||
else None
|
||||
)
|
||||
with patch(
|
||||
"homeassistant.components.recorder.Recorder.async_nightly_tasks",
|
||||
side_effect=nightly,
|
||||
@@ -1325,6 +1341,10 @@ async def async_setup_recorder_instance(
|
||||
"homeassistant.components.recorder.Recorder._migrate_context_ids",
|
||||
side_effect=migrate_context_ids,
|
||||
autospec=True,
|
||||
), patch(
|
||||
"homeassistant.components.recorder.Recorder._migrate_event_type_ids",
|
||||
side_effect=migrate_event_type_ids,
|
||||
autospec=True,
|
||||
):
|
||||
|
||||
async def async_setup_recorder(
|
||||
|
||||
Reference in New Issue
Block a user