File tree Expand file tree Collapse file tree 3 files changed +39
-1
lines changed Expand file tree Collapse file tree 3 files changed +39
-1
lines changed Original file line number Diff line number Diff line change 1- GRAPH_VERSION = 15
1+ GRAPH_VERSION = 16
Original file line number Diff line number Diff line change 1717from .m013_convert_git_password_credential import Migration013
1818from .m014_remove_index_attr_value import Migration014
1919from .m015_diff_format_update import Migration015
20+ from .m016_diff_delete_bug_fix import Migration016
2021
2122if TYPE_CHECKING :
2223 from infrahub .core .root import Root
3940 Migration013 ,
4041 Migration014 ,
4142 Migration015 ,
43+ Migration016 ,
4244]
4345
4446
Original file line number Diff line number Diff line change 1+ from __future__ import annotations
2+
3+ from typing import TYPE_CHECKING
4+
5+ from infrahub .core import registry
6+ from infrahub .core .diff .repository .repository import DiffRepository
7+ from infrahub .core .migrations .shared import MigrationResult
8+ from infrahub .dependencies .registry import build_component_registry , get_component_registry
9+ from infrahub .log import get_logger
10+
11+ from ..shared import ArbitraryMigration
12+
13+ if TYPE_CHECKING :
14+ from infrahub .database import InfrahubDatabase
15+
16+ log = get_logger ()
17+
18+
19+ class Migration016 (ArbitraryMigration ):
20+ name : str = "016_diff_delete_bug_fix_update"
21+ minimum_version : int = 15
22+
23+ async def validate_migration (self , db : InfrahubDatabase ) -> MigrationResult :
24+ result = MigrationResult ()
25+
26+ return result
27+
28+ async def execute (self , db : InfrahubDatabase ) -> MigrationResult :
29+ default_branch = registry .get_branch_from_registry ()
30+ build_component_registry ()
31+ component_registry = get_component_registry ()
32+ diff_repo = await component_registry .get_component (DiffRepository , db = db , branch = default_branch )
33+
34+ diff_roots = await diff_repo .get_empty_roots ()
35+ await diff_repo .delete_diff_roots (diff_root_uuids = [d .uuid for d in diff_roots ])
36+ return MigrationResult ()
You can’t perform that action at this time.
0 commit comments