Skip to content

Commit 6878f6f

Browse files
authored
Add generate_template to node and generic schema (#5910)
1 parent 62a2b9e commit 6878f6f

File tree

3 files changed

+51
-1
lines changed

3 files changed

+51
-1
lines changed
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
GRAPH_VERSION = 19
1+
GRAPH_VERSION = 20

backend/infrahub/core/migrations/graph/__init__.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
from .m017_add_core_profile import Migration017
2222
from .m018_uniqueness_nulls import Migration018
2323
from .m019_restore_rels_to_time import Migration019
24+
from .m020_add_generate_template_attr import Migration020
2425

2526
if TYPE_CHECKING:
2627
from infrahub.core.root import Root
@@ -47,6 +48,7 @@
4748
Migration017,
4849
Migration018,
4950
Migration019,
51+
Migration020,
5052
]
5153

5254

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
from __future__ import annotations
2+
3+
from typing import TYPE_CHECKING, Any
4+
5+
from typing_extensions import Self
6+
7+
from infrahub.core.constants import SchemaPathType
8+
from infrahub.core.migrations.shared import MigrationResult
9+
from infrahub.core.path import SchemaPath
10+
11+
from ..schema.node_attribute_add import NodeAttributeAddMigration
12+
from ..shared import InternalSchemaMigration
13+
14+
if TYPE_CHECKING:
15+
from infrahub.database import InfrahubDatabase
16+
17+
18+
class Migration020(InternalSchemaMigration):
19+
name: str = "020_add_generate_template_attr"
20+
minimum_version: int = 19
21+
22+
@classmethod
23+
def init(cls, **kwargs: dict[str, Any]) -> Self:
24+
internal_schema = cls.get_internal_schema()
25+
schema_node = internal_schema.get_node(name="SchemaNode")
26+
schema_generic = internal_schema.get_node(name="SchemaGeneric")
27+
28+
migrations = [
29+
NodeAttributeAddMigration(
30+
new_node_schema=schema_node,
31+
previous_node_schema=schema_node,
32+
schema_path=SchemaPath(
33+
schema_kind="SchemaNode", path_type=SchemaPathType.ATTRIBUTE, field_name="generate_template"
34+
),
35+
),
36+
NodeAttributeAddMigration(
37+
new_node_schema=schema_generic,
38+
previous_node_schema=schema_generic,
39+
schema_path=SchemaPath(
40+
schema_kind="SchemaNode", path_type=SchemaPathType.ATTRIBUTE, field_name="generate_template"
41+
),
42+
),
43+
]
44+
return cls(migrations=migrations, **kwargs) # type: ignore[arg-type]
45+
46+
async def validate_migration(self, db: InfrahubDatabase) -> MigrationResult: # noqa: ARG002
47+
result = MigrationResult()
48+
return result

0 commit comments

Comments
 (0)