1
0
mirror of https://github.com/home-assistant/core.git synced 2025-12-25 05:26:47 +00:00

Reduce overhead of legacy database columns on new installs (#90246)

* Reduce overhead of legacy database columns on new installs

* Reduce overhead of legacy database columns on new installs

* Reduce overhead of legacy database columns on new installs

* Reduce overhead of legacy database columns on new installs

* not working as expected

* override the type compiler

* override the type compiler

* override the type compiler

* override the type compiler

* Apply suggestions from code review

* pgsql char1

* make entity filter test setup with old schema

* fix some more tests that were mutating state

* fix some more tests that were mutating state

* fix some more tests that were mutating state

* fix more dbstate mutations

* add shim for older tests

* split migration tests

* add coverage for purging legacy data

* tweak

* more fixes

* drop some legacy

* fix another test

* fix a few more

* add casts for postgresql in case someone deletes the schema changes table

* dry

* dry

* dry
This commit is contained in:
J. Nick Koston
2023-04-10 04:08:46 -10:00
committed by GitHub
parent 14b95ffe3a
commit 49079691d4
17 changed files with 2415 additions and 1254 deletions

View File

@@ -4657,7 +4657,7 @@ async def test_validate_statistics_unit_change_no_conversion(
assert response["result"] == expected_result
async def assert_statistic_ids(expected_result):
with session_scope(hass=hass) as session:
with session_scope(hass=hass, read_only=True) as session:
db_states = list(session.query(StatisticsMeta))
assert len(db_states) == len(expected_result)
for i in range(len(db_states)):
@@ -4792,7 +4792,7 @@ async def test_validate_statistics_unit_change_equivalent_units(
assert response["result"] == expected_result
async def assert_statistic_ids(expected_result):
with session_scope(hass=hass) as session:
with session_scope(hass=hass, read_only=True) as session:
db_states = list(session.query(StatisticsMeta))
assert len(db_states) == len(expected_result)
for i in range(len(db_states)):
@@ -4878,7 +4878,7 @@ async def test_validate_statistics_unit_change_equivalent_units_2(
assert response["result"] == expected_result
async def assert_statistic_ids(expected_result):
with session_scope(hass=hass) as session:
with session_scope(hass=hass, read_only=True) as session:
db_states = list(session.query(StatisticsMeta))
assert len(db_states) == len(expected_result)
for i in range(len(db_states)):
@@ -5143,7 +5143,7 @@ async def test_exclude_attributes(
await async_wait_recording_done(hass)
def _fetch_states() -> list[State]:
with session_scope(hass=hass) as session:
with session_scope(hass=hass, read_only=True) as session:
native_states = []
for db_state, db_state_attributes, db_states_meta in (
session.query(States, StateAttributes, StatesMeta)