-
Notifications
You must be signed in to change notification settings - Fork 47
IFC-2048: Remove optional and unique attributes from profile schema #8577
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
Merged
solababs
merged 24 commits into
stable
from
sb-11032025-remove-optional-and-unique-attributes-from-profile-schema-ifc-2048
Apr 23, 2026
Merged
Changes from all commits
Commits
Show all changes
24 commits
Select commit
Hold shift + click to select a range
2f898e0
IFC-2048: Remove optional and unique attributes from profile schema
solababs 867f4e9
add news fragment
solababs 54a24a0
add condition for uique attributes
solababs 6cccd11
update profile support
solababs 8a4dfe4
update profile support condition
solababs ccdeb0b
add uniqueness constraint migration
solababs 085367b
update support profile condition
solababs 9f96aa1
update docs
solababs 5076c39
update json schema
solababs 8310cfb
consolidate condition into one function
solababs 3601dbd
update profile support condition
solababs b775fdb
fix condition
solababs a240ef3
update condition
solababs 3ca7acc
add template check
solababs 3ca60d4
add integration test
solababs d293992
update tests
solababs 7a7ffa7
update tests
solababs 9a8a667
update tests
solababs c3b615f
update test
solababs 36fcd53
update test
solababs 20d484c
refractor migration
solababs 7346fd2
remove templates implementation
solababs 51912b0
update tests
solababs e4d4abb
Merge branch 'stable' into sb-11032025-remove-optional-and-unique-att…
solababs File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
68 changes: 68 additions & 0 deletions
68
backend/infrahub/core/migrations/schema/node_uniqueness_constraints_update.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,68 @@ | ||
| from __future__ import annotations | ||
|
|
||
| from typing import TYPE_CHECKING, Sequence | ||
|
|
||
| from infrahub.core.constants import SchemaPathType | ||
| from infrahub.core.path import SchemaPath | ||
| from infrahub.core.schema.generic_schema import GenericSchema | ||
| from infrahub.core.schema.node_schema import NodeSchema | ||
|
|
||
| from ..query import MigrationBaseQuery # noqa: TC001 | ||
| from ..shared import AttributeSchemaMigration, MigrationInput, MigrationResult, SchemaMigration | ||
| from .attribute_supports_generated_schema import ( | ||
| ProfilesAttributeAddMigrationQuery, | ||
| ProfilesAttributeRemoveMigrationQuery, | ||
| ) | ||
|
|
||
| if TYPE_CHECKING: | ||
| from infrahub.core.branch.models import Branch | ||
|
|
||
|
|
||
| class NodeUniquenessConstraintsUpdateMigration(SchemaMigration): | ||
| name: str = "node.uniqueness_constraints.update" | ||
| queries: Sequence[type[MigrationBaseQuery]] = [] | ||
|
|
||
| async def execute( | ||
| self, | ||
| migration_input: MigrationInput, | ||
| branch: Branch, | ||
| queries: Sequence[type[MigrationBaseQuery]] | None = None, # noqa: ARG002 | ||
| ) -> MigrationResult: | ||
| result = MigrationResult() | ||
|
|
||
| if not isinstance(self.new_schema, (NodeSchema, GenericSchema)): | ||
| return result | ||
|
|
||
| for attr in self.new_schema.attributes: | ||
| prev_attr = self.previous_schema.get_attribute_or_none(name=attr.name) or attr | ||
| previous_supports_profiles = self.previous_schema.check_if_attr_supports_profiles( | ||
| attribute_schema=prev_attr | ||
| ) | ||
| new_supports_profiles = self.new_schema.check_if_attr_supports_profiles(attribute_schema=attr) | ||
|
|
||
| if not self.new_schema.generate_profile or previous_supports_profiles == new_supports_profiles: | ||
| continue | ||
|
|
||
| attr_migration = AttributeSchemaMigration( | ||
| name=f"node.uniqueness_constraints.update.{attr.name}", | ||
| queries=[ | ||
| ProfilesAttributeRemoveMigrationQuery | ||
| if new_supports_profiles is False | ||
| else ProfilesAttributeAddMigrationQuery | ||
| ], | ||
| new_node_schema=self.new_node_schema, | ||
| previous_node_schema=self.previous_node_schema, | ||
| schema_path=SchemaPath( | ||
| path_type=SchemaPathType.ATTRIBUTE, | ||
| schema_kind=self.new_schema.kind, | ||
| field_name=attr.name, | ||
| ), | ||
| ) | ||
|
|
||
| attr_result = await attr_migration.execute(migration_input=migration_input, branch=branch) | ||
| result.errors.extend(attr_result.errors) | ||
| result.nbr_migrations_executed += attr_result.nbr_migrations_executed | ||
| if result.errors: | ||
| break | ||
|
|
||
| return result | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.