Adjust warning message when recorder is doing offline migration (#122509)

* Adjust warning message when recorder is doing offline migration

* Address review comments
This commit is contained in:
Erik Montnemery 2024-07-29 11:38:36 +02:00 committed by GitHub
parent efaf75f2e6
commit 5467685bd8
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -120,6 +120,13 @@ if TYPE_CHECKING:
from . import Recorder
LIVE_MIGRATION_MIN_SCHEMA_VERSION = 0
MIGRATION_NOTE_OFFLINE = (
"Note: this may take several hours on large databases and slow machines. "
"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!"
)
_EMPTY_ENTITY_ID = "missing.entity_id"
_EMPTY_EVENT_TYPE = "missing_event_type"
@ -276,9 +283,12 @@ def _migrate_schema(
if current_version < end_version:
_LOGGER.warning(
"Database is about to upgrade from schema version: %s to: %s",
"The database is about to upgrade from schema version %s to %s%s",
current_version,
end_version,
f". {MIGRATION_NOTE_OFFLINE}"
if current_version < LIVE_MIGRATION_MIN_SCHEMA_VERSION
else "",
)
schema_status = dataclass_replace(schema_status, current_version=end_version)
@ -362,7 +372,7 @@ def _create_index(
_LOGGER.debug("Creating %s index", index_name)
_LOGGER.warning(
"Adding index `%s` to table `%s`. Note: this can take several "
"minutes on large databases and slow computers. Please "
"minutes on large databases and slow machines. Please "
"be patient!",
index_name,
table_name,
@ -411,7 +421,7 @@ def _drop_index(
"""
_LOGGER.warning(
"Dropping index `%s` from table `%s`. Note: this can take several "
"minutes on large databases and slow computers. Please "
"minutes on large databases and slow machines. Please "
"be patient!",
index_name,
table_name,
@ -462,7 +472,7 @@ def _add_columns(
_LOGGER.warning(
(
"Adding columns %s to table %s. Note: this can take several "
"minutes on large databases and slow computers. Please "
"minutes on large databases and slow machines. Please "
"be patient!"
),
", ".join(column.split(" ")[0] for column in columns_def),
@ -524,7 +534,7 @@ def _modify_columns(
_LOGGER.warning(
(
"Modifying columns %s in table %s. Note: this can take several "
"minutes on large databases and slow computers. Please "
"minutes on large databases and slow machines. Please "
"be patient!"
),
", ".join(column.split(" ")[0] for column in columns_def),
@ -1554,7 +1564,7 @@ def _correct_table_character_set_and_collation(
_LOGGER.warning(
"Updating character set and collation of table %s to utf8mb4. "
"Note: this can take several minutes on large databases and slow "
"computers. Please be patient!",
"machines. Please be patient!",
table,
)
with (