Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bug: duplicated inherited schema rels and attrs prevent schema updates #5793

Open
exalate-issue-sync bot opened this issue Feb 19, 2025 · 0 comments
Open
Assignees
Labels
priority/2 This issue stalls work on the project or its dependents, it's a blocker for a release state/planned This issue is planned to be worked on in an upcoming release.

Comments

@exalate-issue-sync
Copy link

We prevent updating relationships and attributes on generic nodes and the schema nodes that inherit from the generic nodes correctly b/c of duplicated information in the database. Updating a relationship/attribute identifier/name requires including an ID in the schema and that ID corresponds to a {{SchemaRelationship}} or {{SchemaAttribute}} node in the database. But if these attributes/relationships are duplicated on the database, then there are multiple nodes with different IDs associated with the relationship/attribute and that prevents the schema update from functioning correctly

We save inherited relationships and attributes on both the {{SchemaGeneric}} node that defines them and the {{SchemaNode}} node that inherits them. This is duplicative. We only need to save them on the {{SchemaGeneric}} and the logic for loading/updating a schema in memory can handle adding/update the inherited relationships/attributes in memory.

here is a semi-helpful database screenshot of the problem. The red node is a {{SchemaGeneric}} and the green node is {{SchemaNode}} that inherits from that generic.

!image-20250131-185316.png|width=75%,alt="image-20250131-185316.png"!

the problem areas of the code are the {{load_node_to_db}}, {{update_node_in_db}}, and {{update_node_in_db_based_on_diff}} methods of the {{SchemaBranch}} class. they use {{node.attributes}} and {{node.relationships}} where they should use {{node.local_attributes}} and {{node.local_relationships}}, which exclude the inherited attributes/relationships.

this change will also require a migration to remove the duplicated data from existing databases.

@exalate-issue-sync exalate-issue-sync bot added priority/2 This issue stalls work on the project or its dependents, it's a blocker for a release state/planned This issue is planned to be worked on in an upcoming release. labels Feb 19, 2025
@exalate-issue-sync exalate-issue-sync bot added this to the Infrahub - 1.2 milestone Feb 19, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
priority/2 This issue stalls work on the project or its dependents, it's a blocker for a release state/planned This issue is planned to be worked on in an upcoming release.
Projects
None yet
Development

No branches or pull requests

1 participant