diff --git a/homeassistant/components/recorder/statistics.py b/homeassistant/components/recorder/statistics.py index b117556b0af..989dc06db57 100644 --- a/homeassistant/components/recorder/statistics.py +++ b/homeassistant/components/recorder/statistics.py @@ -2590,8 +2590,8 @@ def _validate_db_schema( for column in columns: if stored[column] != expected[column]: schema_errors.add(f"{table_name}.{supports}") - _LOGGER.debug( - "Column %s in database table %s does not support %s (%s != %s)", + _LOGGER.error( + "Column %s in database table %s does not support %s (stored=%s != expected=%s)", column, table_name, supports, @@ -2727,18 +2727,14 @@ def correct_db_schema( ], ) if f"{table.__tablename__}.µs precision" in schema_errors: - # Attempt to convert datetime columns to µs precision - if instance.dialect_name == SupportedDialect.MYSQL: - datetime_type = "DATETIME(6)" - else: - datetime_type = "TIMESTAMP(6) WITH TIME ZONE" + # Attempt to convert timestamp columns to µs precision _modify_columns( session_maker, engine, table.__tablename__, [ - f"last_reset {datetime_type}", - f"start {datetime_type}", + "last_reset_ts DOUBLE PRECISION", + "start_ts DOUBLE PRECISION", ], ) diff --git a/tests/components/recorder/test_statistics.py b/tests/components/recorder/test_statistics.py index ad4d0de410e..d783d72be2d 100644 --- a/tests/components/recorder/test_statistics.py +++ b/tests/components/recorder/test_statistics.py @@ -1687,12 +1687,12 @@ async def test_validate_db_schema_fix_float_issue( @pytest.mark.parametrize( ("db_engine", "modification"), ( - ("mysql", ["last_reset DATETIME(6)", "start DATETIME(6)"]), + ("mysql", ["last_reset_ts DOUBLE PRECISION", "start_ts DOUBLE PRECISION"]), ( "postgresql", [ - "last_reset TIMESTAMP(6) WITH TIME ZONE", - "start TIMESTAMP(6) WITH TIME ZONE", + "last_reset_ts DOUBLE PRECISION", + "start_ts DOUBLE PRECISION", ], ), ),