From 5467685bd8d8390f465bee122234f5e9c6f5a1bd Mon Sep 17 00:00:00 2001 From: Erik Montnemery Date: Mon, 29 Jul 2024 11:38:36 +0200 Subject: [PATCH] Adjust warning message when recorder is doing offline migration (#122509) * Adjust warning message when recorder is doing offline migration * Address review comments --- .../components/recorder/migration.py | 22 ++++++++++++++----- 1 file changed, 16 insertions(+), 6 deletions(-) diff --git a/homeassistant/components/recorder/migration.py b/homeassistant/components/recorder/migration.py index 6f438106ab6..d7c5e7f0ea0 100644 --- a/homeassistant/components/recorder/migration.py +++ b/homeassistant/components/recorder/migration.py @@ -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 (