-
Notifications
You must be signed in to change notification settings - Fork 22
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add
generate_template
to node and generic schema
- Loading branch information
Showing
3 changed files
with
51 additions
and
1 deletion.
There are no files selected for viewing
This file contains 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 |
---|---|---|
@@ -1 +1 @@ | ||
GRAPH_VERSION = 19 | ||
GRAPH_VERSION = 20 |
This file contains 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
48 changes: 48 additions & 0 deletions
48
backend/infrahub/core/migrations/graph/m020_add_generate_template_attr.py
This file contains 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,48 @@ | ||
from __future__ import annotations | ||
|
||
from typing import TYPE_CHECKING, Any | ||
|
||
from typing_extensions import Self | ||
|
||
from infrahub.core.constants import SchemaPathType | ||
from infrahub.core.migrations.shared import MigrationResult | ||
from infrahub.core.path import SchemaPath | ||
|
||
from ..schema.node_attribute_add import NodeAttributeAddMigration | ||
from ..shared import InternalSchemaMigration | ||
|
||
if TYPE_CHECKING: | ||
from infrahub.database import InfrahubDatabase | ||
|
||
|
||
class Migration020(InternalSchemaMigration): | ||
name: str = "020_add_generate_template_attr" | ||
minimum_version: int = 19 | ||
|
||
@classmethod | ||
def init(cls, **kwargs: dict[str, Any]) -> Self: | ||
internal_schema = cls.get_internal_schema() | ||
schema_node = internal_schema.get_node(name="SchemaNode") | ||
schema_generic = internal_schema.get_node(name="SchemaGeneric") | ||
|
||
migrations = [ | ||
NodeAttributeAddMigration( | ||
new_node_schema=schema_node, | ||
previous_node_schema=schema_node, | ||
schema_path=SchemaPath( | ||
schema_kind="SchemaNode", path_type=SchemaPathType.ATTRIBUTE, field_name="generate_template" | ||
), | ||
), | ||
NodeAttributeAddMigration( | ||
new_node_schema=schema_generic, | ||
previous_node_schema=schema_generic, | ||
schema_path=SchemaPath( | ||
schema_kind="SchemaNode", path_type=SchemaPathType.ATTRIBUTE, field_name="generate_template" | ||
), | ||
), | ||
] | ||
return cls(migrations=migrations, **kwargs) # type: ignore[arg-type] | ||
|
||
async def validate_migration(self, db: InfrahubDatabase) -> MigrationResult: # noqa: ARG002 | ||
result = MigrationResult() | ||
return result |