Component
API Server / GraphQL
Infrahub version
1.8.2
Current Behavior
updating an attribute on a schema that is used as a sub-template (another schema with generate_template=True has a COMPONENT relationship to this schema) does not cause the attribute to be added to existing instances of templates for this schema if generate_template is False on this schema
Expected Behavior
sub-template instances should be correctly updated when a new attribute is added to a schema or an attribute on the schema is updated to be added to the linked template schema
Steps to Reproduce
Reproduction Steps
- Define two node schemas:
TestDevice with generate_template=True and a Component relationship to TestPart, and TestPart with generate_template=False (default).
- Load and process the schema. Observe that
TemplateTestPart is automatically generated as a sub-template because TestPart is a Component of TestDevice.
- On
TestPart, define an attribute (e.g., serial_number) with read_only=True. Because support_templates is read_only is False and unique is False, this attribute is excluded from TemplateTestPart nodes.
- Create a
TemplateTestPart instance in the database. Confirm it does not have a serial_number attribute.
- Update the schema to change
TestPart.serial_number from read_only=True to read_only=False. This flips support_templates from False to True.
- The schema diff detects
attribute.read_only.update and triggers AttributeSupportsGeneratedSchemaMigration.
- Expected: The migration adds
serial_number to all existing TemplateTestPart nodes.
- Actual: The migration silently skips the template update. The condition at
backend/infrahub/core/migrations/schema/attribute_supports_generated_schema.py:139 checks self.new_schema.generate_template, which is False for TestPart. The migration only runs for schemas that explicitly set generate_template=True, missing all sub-templates that exist due to Component/Parent relationships from other schemas.
Additional Information
No response
Component
API Server / GraphQL
Infrahub version
1.8.2
Current Behavior
updating an attribute on a schema that is used as a sub-template (another schema with
generate_template=Truehas a COMPONENT relationship to this schema) does not cause the attribute to be added to existing instances of templates for this schema ifgenerate_templateis False on this schemaExpected Behavior
sub-template instances should be correctly updated when a new attribute is added to a schema or an attribute on the schema is updated to be added to the linked template schema
Steps to Reproduce
Reproduction Steps
TestDevicewithgenerate_template=Trueand a Component relationship toTestPart, andTestPartwithgenerate_template=False(default).TemplateTestPartis automatically generated as a sub-template becauseTestPartis a Component ofTestDevice.TestPart, define an attribute (e.g.,serial_number) withread_only=True. Becausesupport_templatesisread_only is False and unique is False, this attribute is excluded fromTemplateTestPartnodes.TemplateTestPartinstance in the database. Confirm it does not have aserial_numberattribute.TestPart.serial_numberfromread_only=Truetoread_only=False. This flipssupport_templatesfromFalsetoTrue.attribute.read_only.updateand triggersAttributeSupportsGeneratedSchemaMigration.serial_numberto all existingTemplateTestPartnodes.backend/infrahub/core/migrations/schema/attribute_supports_generated_schema.py:139checksself.new_schema.generate_template, which isFalseforTestPart. The migration only runs for schemas that explicitly setgenerate_template=True, missing all sub-templates that exist due to Component/Parent relationships from other schemas.Additional Information
No response