mirror of
https://github.com/home-assistant/core.git
synced 2025-07-18 18:57:06 +00:00
Deduplicate warning messages in recorder DB migration (#124845)
This commit is contained in:
parent
4dfc11a140
commit
7bb93d4f3e
@ -128,6 +128,11 @@ MIGRATION_NOTE_OFFLINE = (
|
|||||||
"Home Assistant will not start until the upgrade is completed. Please be patient "
|
"Home Assistant will not start until the upgrade is completed. Please be patient "
|
||||||
"and do not turn off or restart Home Assistant while the upgrade is in progress!"
|
"and do not turn off or restart Home Assistant while the upgrade is in progress!"
|
||||||
)
|
)
|
||||||
|
MIGRATION_NOTE_MINUTES = (
|
||||||
|
"Note: this may take several minutes on large databases and slow machines. "
|
||||||
|
"Please be patient!"
|
||||||
|
)
|
||||||
|
MIGRATION_NOTE_WHILE = "This will take a while; please be patient!"
|
||||||
|
|
||||||
_EMPTY_ENTITY_ID = "missing.entity_id"
|
_EMPTY_ENTITY_ID = "missing.entity_id"
|
||||||
_EMPTY_EVENT_TYPE = "missing_event_type"
|
_EMPTY_EVENT_TYPE = "missing_event_type"
|
||||||
@ -373,11 +378,10 @@ def _create_index(
|
|||||||
index = index_list[0]
|
index = index_list[0]
|
||||||
_LOGGER.debug("Creating %s index", index_name)
|
_LOGGER.debug("Creating %s index", index_name)
|
||||||
_LOGGER.warning(
|
_LOGGER.warning(
|
||||||
"Adding index `%s` to table `%s`. Note: this can take several "
|
"Adding index `%s` to table `%s`. %s",
|
||||||
"minutes on large databases and slow machines. Please "
|
|
||||||
"be patient!",
|
|
||||||
index_name,
|
index_name,
|
||||||
table_name,
|
table_name,
|
||||||
|
MIGRATION_NOTE_MINUTES,
|
||||||
)
|
)
|
||||||
with session_scope(session=session_maker()) as session:
|
with session_scope(session=session_maker()) as session:
|
||||||
try:
|
try:
|
||||||
@ -422,11 +426,10 @@ def _drop_index(
|
|||||||
DO NOT USE THIS FUNCTION IN ANY OPERATION THAT TAKES USER INPUT.
|
DO NOT USE THIS FUNCTION IN ANY OPERATION THAT TAKES USER INPUT.
|
||||||
"""
|
"""
|
||||||
_LOGGER.warning(
|
_LOGGER.warning(
|
||||||
"Dropping index `%s` from table `%s`. Note: this can take several "
|
"Dropping index `%s` from table `%s`. %s",
|
||||||
"minutes on large databases and slow machines. Please "
|
|
||||||
"be patient!",
|
|
||||||
index_name,
|
index_name,
|
||||||
table_name,
|
table_name,
|
||||||
|
MIGRATION_NOTE_MINUTES,
|
||||||
)
|
)
|
||||||
index_to_drop: str | None = None
|
index_to_drop: str | None = None
|
||||||
with session_scope(session=session_maker()) as session:
|
with session_scope(session=session_maker()) as session:
|
||||||
@ -472,13 +475,10 @@ def _add_columns(
|
|||||||
) -> None:
|
) -> None:
|
||||||
"""Add columns to a table."""
|
"""Add columns to a table."""
|
||||||
_LOGGER.warning(
|
_LOGGER.warning(
|
||||||
(
|
"Adding columns %s to table %s. %s",
|
||||||
"Adding columns %s to table %s. Note: this can take several "
|
|
||||||
"minutes on large databases and slow machines. Please "
|
|
||||||
"be patient!"
|
|
||||||
),
|
|
||||||
", ".join(column.split(" ")[0] for column in columns_def),
|
", ".join(column.split(" ")[0] for column in columns_def),
|
||||||
table_name,
|
table_name,
|
||||||
|
MIGRATION_NOTE_MINUTES,
|
||||||
)
|
)
|
||||||
|
|
||||||
columns_def = [f"ADD {col_def}" for col_def in columns_def]
|
columns_def = [f"ADD {col_def}" for col_def in columns_def]
|
||||||
@ -534,13 +534,10 @@ def _modify_columns(
|
|||||||
return
|
return
|
||||||
|
|
||||||
_LOGGER.warning(
|
_LOGGER.warning(
|
||||||
(
|
"Modifying columns %s in table %s. %s",
|
||||||
"Modifying columns %s in table %s. Note: this can take several "
|
|
||||||
"minutes on large databases and slow machines. Please "
|
|
||||||
"be patient!"
|
|
||||||
),
|
|
||||||
", ".join(column.split(" ")[0] for column in columns_def),
|
", ".join(column.split(" ")[0] for column in columns_def),
|
||||||
table_name,
|
table_name,
|
||||||
|
MIGRATION_NOTE_MINUTES,
|
||||||
)
|
)
|
||||||
|
|
||||||
if engine.dialect.name == SupportedDialect.POSTGRESQL:
|
if engine.dialect.name == SupportedDialect.POSTGRESQL:
|
||||||
@ -1781,10 +1778,9 @@ def _migrate_statistics_columns_to_timestamp_removing_duplicates(
|
|||||||
except IntegrityError as ex:
|
except IntegrityError as ex:
|
||||||
_LOGGER.error(
|
_LOGGER.error(
|
||||||
"Statistics table contains duplicate entries: %s; "
|
"Statistics table contains duplicate entries: %s; "
|
||||||
"Cleaning up duplicates and trying again; "
|
"Cleaning up duplicates and trying again; %s",
|
||||||
"This will take a while; "
|
|
||||||
"Please be patient!",
|
|
||||||
ex,
|
ex,
|
||||||
|
MIGRATION_NOTE_WHILE,
|
||||||
)
|
)
|
||||||
# There may be duplicated statistics entries, delete duplicates
|
# There may be duplicated statistics entries, delete duplicates
|
||||||
# and try again
|
# and try again
|
||||||
@ -1812,10 +1808,9 @@ def _correct_table_character_set_and_collation(
|
|||||||
"""Correct issues detected by validate_db_schema."""
|
"""Correct issues detected by validate_db_schema."""
|
||||||
# Attempt to convert the table to utf8mb4
|
# Attempt to convert the table to utf8mb4
|
||||||
_LOGGER.warning(
|
_LOGGER.warning(
|
||||||
"Updating character set and collation of table %s to utf8mb4. "
|
"Updating character set and collation of table %s to utf8mb4. %s",
|
||||||
"Note: this can take several minutes on large databases and slow "
|
|
||||||
"machines. Please be patient!",
|
|
||||||
table,
|
table,
|
||||||
|
MIGRATION_NOTE_MINUTES,
|
||||||
)
|
)
|
||||||
with (
|
with (
|
||||||
contextlib.suppress(SQLAlchemyError),
|
contextlib.suppress(SQLAlchemyError),
|
||||||
@ -2736,10 +2731,7 @@ def rebuild_sqlite_table(
|
|||||||
orig_name = table_table.name
|
orig_name = table_table.name
|
||||||
temp_name = f"{table_table.name}_temp_{int(time())}"
|
temp_name = f"{table_table.name}_temp_{int(time())}"
|
||||||
|
|
||||||
_LOGGER.warning(
|
_LOGGER.warning("Rebuilding SQLite table %s; %s", orig_name, MIGRATION_NOTE_WHILE)
|
||||||
"Rebuilding SQLite table %s; This will take a while; Please be patient!",
|
|
||||||
orig_name,
|
|
||||||
)
|
|
||||||
|
|
||||||
try:
|
try:
|
||||||
# 12 step SQLite table rebuild
|
# 12 step SQLite table rebuild
|
||||||
|
Loading…
x
Reference in New Issue
Block a user