diff --git a/backend/infrahub/cli/db.py b/backend/infrahub/cli/db.py index 33012f66a0..1fbaebc2a1 100644 --- a/backend/infrahub/cli/db.py +++ b/backend/infrahub/cli/db.py @@ -210,7 +210,7 @@ async def update_core_schema( # pylint: disable=too-many-statements candidate_schema.load_schema(schema=SchemaRoot(**deprecated_models)) candidate_schema.process() - result = branch_schema.validate_update(other=candidate_schema) + result = branch_schema.validate_update(other=candidate_schema, enforce_update_support=False) if result.errors: rprint(f"{error_badge} | Unable to update the schema, due to failed validations") for error in result.errors: diff --git a/backend/infrahub/core/models.py b/backend/infrahub/core/models.py index 4628ad6758..55448323ab 100644 --- a/backend/infrahub/core/models.py +++ b/backend/infrahub/core/models.py @@ -135,11 +135,12 @@ class SchemaUpdateValidationResult(BaseModel): errors: list[SchemaUpdateValidationError] = Field(default_factory=list) constraints: list[SchemaUpdateConstraintInfo] = Field(default_factory=list) migrations: list[SchemaUpdateMigrationInfo] = Field(default_factory=list) + enforce_update_support: bool = True diff: SchemaDiff @classmethod - def init(cls, diff: SchemaDiff, schema: SchemaBranch) -> Self: - obj = cls(diff=diff) + def init(cls, diff: SchemaDiff, schema: SchemaBranch, enforce_update_support: bool = True) -> Self: + obj = cls(diff=diff, enforce_update_support=enforce_update_support) obj.process_diff(schema=schema) return obj @@ -244,7 +245,7 @@ def _process_field( schema_path: SchemaPath, field_update: str, ) -> None: - if field_update == UpdateSupport.NOT_SUPPORTED.value: + if field_update == UpdateSupport.NOT_SUPPORTED.value and self.enforce_update_support: self.errors.append( SchemaUpdateValidationError( path=schema_path, diff --git a/backend/infrahub/core/schema_manager.py b/backend/infrahub/core/schema_manager.py index 1cfbd278a0..a120e2ba58 100644 --- a/backend/infrahub/core/schema_manager.py +++ b/backend/infrahub/core/schema_manager.py @@ -251,9 +251,11 @@ def update(self, schema: SchemaBranch) -> None: # else: # del self.generics[item_kind] - def validate_update(self, other: SchemaBranch) -> SchemaUpdateValidationResult: + def validate_update(self, other: SchemaBranch, enforce_update_support: bool = True) -> SchemaUpdateValidationResult: diff = self.diff(other=other) - result = SchemaUpdateValidationResult.init(diff=diff, schema=other) + result = SchemaUpdateValidationResult.init( + diff=diff, schema=other, enforce_update_support=enforce_update_support + ) result.validate_all(migration_map=MIGRATION_MAP, validator_map=CONSTRAINT_VALIDATOR_MAP) return result