Skip to content

Commit 42edbde

Browse files
committed
Remove Profile in registry for renamed schema nodes
Fixes #4909
1 parent 447131e commit 42edbde

File tree

3 files changed

+13
-0
lines changed

3 files changed

+13
-0
lines changed

backend/infrahub/core/schema/schema_branch.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1642,6 +1642,12 @@ def manage_profile_schemas(self) -> None:
16421642
profile = self.generate_profile_from_node(node=node)
16431643
self.set(name=profile.kind, schema=profile)
16441644
profile_schema_kinds.add(profile.kind)
1645+
1646+
for previous_profile in list(self.profiles.keys()):
1647+
# Ensure that we remove previous profile schemas if a node has been renamed
1648+
if previous_profile not in profile_schema_kinds:
1649+
self.delete(name=previous_profile)
1650+
16451651
if not profile_schema_kinds:
16461652
return
16471653

backend/tests/integration/schema_lifecycle/test_schema_migration_main.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -209,6 +209,12 @@ async def test_step03_load(self, db: InfrahubDatabase, client: InfrahubClient, i
209209
john = persons[0]
210210
assert not hasattr(john, "height")
211211

212+
# Ensure that we can query the existing node with graphql endpoint
213+
api_persons = await client.filters(kind=PERSON_KIND, firstname__value="John")
214+
assert len(api_persons) == 1
215+
api_john = api_persons[0]
216+
assert not hasattr(api_john, "height")
217+
212218
manufacturers = await registry.manager.query(
213219
db=db, schema=MANUFACTURER_KIND_03, filters={"name__value": "honda"}
214220
)

changelog/4909.fixed.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Remove Profile in registry for renamed schema nodes

0 commit comments

Comments
 (0)