Skip to content

Commit d9d126b

Browse files
committed
Rename class
1 parent f684192 commit d9d126b

File tree

5 files changed

+15
-18
lines changed

5 files changed

+15
-18
lines changed

backend/infrahub/cli/db.py

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -35,10 +35,7 @@
3535
GraphRelationshipIsPartOf,
3636
GraphRelationshipProperties,
3737
)
38-
from infrahub.core.initialization import (
39-
get_root_node,
40-
initialize_registry,
41-
)
38+
from infrahub.core.initialization import get_root_node, initialize_registry
4239
from infrahub.core.migrations.graph import get_graph_migrations, get_migration_by_number
4340
from infrahub.core.migrations.schema.models import SchemaApplyMigrationData
4441
from infrahub.core.migrations.schema.tasks import schema_apply_migrations
@@ -69,7 +66,7 @@ def get_timestamp_string() -> str:
6966
ArbitraryMigration,
7067
GraphMigration,
7168
InternalSchemaMigration,
72-
MigrationWithRebase,
69+
MigrationRequiringRebase,
7370
)
7471
from infrahub.database import InfrahubDatabase
7572
from infrahub.database.index import IndexManagerBase
@@ -289,10 +286,10 @@ async def index(
289286

290287
async def detect_migration_to_run(
291288
current_graph_version: int, migration_number: int | str | None = None
292-
) -> Sequence[GraphMigration | InternalSchemaMigration | ArbitraryMigration | MigrationWithRebase]:
289+
) -> Sequence[GraphMigration | InternalSchemaMigration | ArbitraryMigration | MigrationRequiringRebase]:
293290
"""Return a sequence of migrations to apply to upgrade the database."""
294291
rprint("Checking current state of the database")
295-
migrations: list[GraphMigration | InternalSchemaMigration | ArbitraryMigration | MigrationWithRebase] = []
292+
migrations: list[GraphMigration | InternalSchemaMigration | ArbitraryMigration | MigrationRequiringRebase] = []
296293

297294
if migration_number:
298295
migration = get_migration_by_number(migration_number)
@@ -319,7 +316,7 @@ async def detect_migration_to_run(
319316

320317
async def migrate_database(
321318
db: InfrahubDatabase,
322-
migrations: Sequence[GraphMigration | InternalSchemaMigration | ArbitraryMigration | MigrationWithRebase],
319+
migrations: Sequence[GraphMigration | InternalSchemaMigration | ArbitraryMigration | MigrationRequiringRebase],
323320
initialize: bool = False,
324321
) -> bool:
325322
"""Apply the latest migrations to the database, this function will print the status directly in the console.

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -47,9 +47,9 @@
4747
from .m043_backfill_hfid_display_label_in_db import Migration043
4848

4949
if TYPE_CHECKING:
50-
from ..shared import ArbitraryMigration, GraphMigration, InternalSchemaMigration, MigrationWithRebase
50+
from ..shared import ArbitraryMigration, GraphMigration, InternalSchemaMigration, MigrationRequiringRebase
5151

52-
MIGRATIONS: list[type[GraphMigration | InternalSchemaMigration | ArbitraryMigration | MigrationWithRebase]] = [
52+
MIGRATIONS: list[type[GraphMigration | InternalSchemaMigration | ArbitraryMigration | MigrationRequiringRebase]] = [
5353
Migration001,
5454
Migration002,
5555
Migration003,
@@ -98,7 +98,7 @@
9898

9999
async def get_graph_migrations(
100100
current_graph_version: int,
101-
) -> Sequence[GraphMigration | InternalSchemaMigration | ArbitraryMigration | MigrationWithRebase]:
101+
) -> Sequence[GraphMigration | InternalSchemaMigration | ArbitraryMigration | MigrationRequiringRebase]:
102102
applicable_migrations = []
103103
for migration_class in MIGRATIONS:
104104
migration = migration_class.init()
@@ -111,7 +111,7 @@ async def get_graph_migrations(
111111

112112
def get_migration_by_number(
113113
migration_number: int | str,
114-
) -> GraphMigration | InternalSchemaMigration | ArbitraryMigration | MigrationWithRebase:
114+
) -> GraphMigration | InternalSchemaMigration | ArbitraryMigration | MigrationRequiringRebase:
115115
# Convert to string and pad with zeros if needed
116116
try:
117117
num = int(migration_number)

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
from infrahub.core.schema.manager import SchemaManager
1515
from infrahub.types import is_large_attribute_type
1616

17-
from ..shared import MigrationWithRebase
17+
from ..shared import MigrationRequiringRebase
1818

1919
if TYPE_CHECKING:
2020
from infrahub.core.branch import Branch
@@ -353,7 +353,7 @@ async def query_init(self, db: InfrahubDatabase, **kwargs: dict[str, Any]) -> No
353353
self.add_to_query(set_value_query)
354354

355355

356-
class Migration043(MigrationWithRebase):
356+
class Migration043(MigrationRequiringRebase):
357357
"""
358358
Backfill `human_friendly_id` and `display_label` attributes for nodes with schemas that define them.
359359
"""

backend/infrahub/core/migrations/runner.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
from infrahub.core.migrations.graph import MIGRATIONS
66

77
from .exceptions import MigrationFailureError
8-
from .shared import MigrationWithRebase
8+
from .shared import MigrationRequiringRebase
99

1010
if TYPE_CHECKING:
1111
from infrahub.core.branch import Branch
@@ -17,9 +17,9 @@ def __init__(self, branch: Branch) -> None:
1717
self.branch = branch
1818
self.applicable_migrations = self._get_applicable_migrations()
1919

20-
def _get_applicable_migrations(self) -> Sequence[MigrationWithRebase]:
20+
def _get_applicable_migrations(self) -> Sequence[MigrationRequiringRebase]:
2121
applicable_migrations = []
22-
for migration_class in [m for m in MIGRATIONS if issubclass(m, MigrationWithRebase)]:
22+
for migration_class in [m for m in MIGRATIONS if issubclass(m, MigrationRequiringRebase)]:
2323
migration = migration_class.init()
2424
if self.branch.graph_version and self.branch.graph_version > migration.minimum_version:
2525
continue

backend/infrahub/core/migrations/shared.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -224,7 +224,7 @@ async def execute(self, db: InfrahubDatabase) -> MigrationResult:
224224
raise NotImplementedError()
225225

226226

227-
class MigrationWithRebase(BaseModel):
227+
class MigrationRequiringRebase(BaseModel):
228228
model_config = ConfigDict(arbitrary_types_allowed=True)
229229
name: str = Field(..., description="Name of the migration")
230230
minimum_version: int = Field(..., description="Minimum version of the graph to execute this migration")

0 commit comments

Comments
 (0)