Skip to content

Commit

Permalink
Remove Profile in registry for renamed schema nodes
Browse files Browse the repository at this point in the history
Fixes #4909
  • Loading branch information
ogenstad committed Nov 13, 2024
1 parent 323a33a commit d500a20
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 0 deletions.
6 changes: 6 additions & 0 deletions backend/infrahub/core/schema/schema_branch.py
Original file line number Diff line number Diff line change
Expand Up @@ -1481,6 +1481,12 @@ def manage_profile_schemas(self) -> None:
profile = self.generate_profile_from_node(node=node)
self.set(name=profile.kind, schema=profile)
profile_schema_kinds.add(profile.kind)

for previous_profile in list(self.profiles.keys()):
# Ensure that we remove previous profile schemas if a node has been renamed
if previous_profile not in profile_schema_kinds:
self.delete(name=previous_profile)

if not profile_schema_kinds:
return

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -209,6 +209,12 @@ async def test_step03_load(self, db: InfrahubDatabase, client: InfrahubClient, i
john = persons[0]
assert not hasattr(john, "height")

# Ensure that we can query the existing node with graphql endpoint
api_persons = await client.filters(kind=PERSON_KIND, firstname__value="John")
assert len(api_persons) == 1
api_john = api_persons[0]
assert not hasattr(api_john, "height")

manufacturers = await registry.manager.query(
db=db, schema=MANUFACTURER_KIND_03, filters={"name__value": "honda"}
)
Expand Down
1 change: 1 addition & 0 deletions changelog/4909.fixed.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Remove Profile in registry for renamed schema nodes

0 comments on commit d500a20

Please sign in to comment.