-
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 a "migration" to delete all diffs b/c of the new format
- Loading branch information
1 parent
1250900
commit 323275e
Showing
5 changed files
with
61 additions
and
4 deletions.
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 = 14 | ||
GRAPH_VERSION = 15 |
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
36 changes: 36 additions & 0 deletions
36
backend/infrahub/core/migrations/graph/m015_diff_format_update.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,36 @@ | ||
from __future__ import annotations | ||
|
||
from typing import TYPE_CHECKING | ||
|
||
from infrahub.core import registry | ||
from infrahub.core.diff.repository.repository import DiffRepository | ||
from infrahub.core.migrations.shared import MigrationResult | ||
from infrahub.dependencies.registry import build_component_registry, get_component_registry | ||
from infrahub.log import get_logger | ||
|
||
from ..shared import ArbitraryMigration | ||
|
||
if TYPE_CHECKING: | ||
from infrahub.database import InfrahubDatabase | ||
|
||
log = get_logger() | ||
|
||
|
||
class Migration015(ArbitraryMigration): | ||
name: str = "015_diff_format_update" | ||
minimum_version: int = 14 | ||
|
||
async def validate_migration(self, db: InfrahubDatabase) -> MigrationResult: | ||
result = MigrationResult() | ||
|
||
return result | ||
|
||
async def execute(self, db: InfrahubDatabase) -> MigrationResult: | ||
default_branch = registry.get_branch_from_registry() | ||
build_component_registry() | ||
component_registry = get_component_registry() | ||
diff_repo = await component_registry.get_component(DiffRepository, db=db, branch=default_branch) | ||
|
||
diff_roots = await diff_repo.get_empty_roots() | ||
await diff_repo.delete_diff_roots(diff_root_uuids=[d.uuid for d in diff_roots]) | ||
return MigrationResult() |
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
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