Skip to content

Commit 6bb0457

Browse files
committed
merge origin/release-1.2
1 parent dd96217 commit 6bb0457

File tree

1 file changed

+48
-0
lines changed

1 file changed

+48
-0
lines changed
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 Migration021(InternalSchemaMigration):
19+
name: str = "021_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)