Remove SchemaValidationStatus.valid (#122394)

pull/122389/head
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
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()
else:
self.migration_in_progress = True
@ -752,7 +752,7 @@ class Recorder(threading.Thread):
self.hass.add_job(self.async_connection_success)
# 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)
if not result:
self._notify_migration_failed()
@ -774,8 +774,8 @@ class Recorder(threading.Thread):
# we restart before startup finishes
return
# Do live migration steps, if needed
if not schema_status.valid:
# Do live migration steps and repairs, if needed
if schema_status.migration_needed or schema_status.schema_errors:
result, schema_status = self._migrate_schema_live_and_setup_run(
schema_status
)

View File

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