Remove SchemaValidationStatus.valid (#122394)

This commit is contained in:
Erik Montnemery 2024-07-22 17:33:13 +02:00 committed by GitHub
parent e8b88557ee
commit b14e8d1609
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 6 additions and 8 deletions

View File

@ -743,7 +743,7 @@ class Recorder(threading.Thread):
return return
self.schema_version = schema_status.current_version self.schema_version = schema_status.current_version
if schema_status.valid: if not schema_status.migration_needed and not schema_status.schema_errors:
self._setup_run() self._setup_run()
else: else:
self.migration_in_progress = True self.migration_in_progress = True
@ -752,7 +752,7 @@ class Recorder(threading.Thread):
self.hass.add_job(self.async_connection_success) self.hass.add_job(self.async_connection_success)
# First do non-live migration steps, if needed # First do non-live migration steps, if needed
if not schema_status.valid: if schema_status.migration_needed:
result, schema_status = self._migrate_schema_offline(schema_status) result, schema_status = self._migrate_schema_offline(schema_status)
if not result: if not result:
self._notify_migration_failed() self._notify_migration_failed()
@ -774,8 +774,8 @@ class Recorder(threading.Thread):
# we restart before startup finishes # we restart before startup finishes
return return
# Do live migration steps, if needed # Do live migration steps and repairs, if needed
if not schema_status.valid: if schema_status.migration_needed or schema_status.schema_errors:
result, schema_status = self._migrate_schema_live_and_setup_run( result, schema_status = self._migrate_schema_live_and_setup_run(
schema_status schema_status
) )

View File

@ -193,9 +193,9 @@ class SchemaValidationStatus:
"""Store schema validation status.""" """Store schema validation status."""
current_version: int current_version: int
migration_needed: bool
schema_errors: set[str] schema_errors: set[str]
start_version: int start_version: int
valid: bool
def _schema_is_current(current_version: int) -> bool: def _schema_is_current(current_version: int) -> bool:
@ -223,10 +223,8 @@ def validate_db_schema(
# columns may otherwise not exist etc. # columns may otherwise not exist etc.
schema_errors = _find_schema_errors(hass, instance, session_maker) schema_errors = _find_schema_errors(hass, instance, session_maker)
valid = is_current and not schema_errors
return SchemaValidationStatus( return SchemaValidationStatus(
current_version, schema_errors, current_version, valid current_version, not is_current, schema_errors, current_version
) )