Skip to content

Commit 6e6004b

Browse files
committed
Fix rebase of branches using upgrade command
1 parent fc092fc commit 6e6004b

File tree

3 files changed

+9
-2
lines changed

3 files changed

+9
-2
lines changed

backend/infrahub/cli/db.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -371,20 +371,24 @@ async def trigger_rebase_branches(db: InfrahubDatabase) -> None:
371371

372372
for branch in branches:
373373
if branch.graph_version == GRAPH_VERSION:
374+
rprint(
375+
f"Ignoring branch rebase and migrations for '{branch.name}' (ID: {branch.uuid}), it is already up-to-date"
376+
)
374377
continue
375378

376379
rprint(f"Rebasing branch '{branch.name}' (ID: {branch.uuid})...", end="")
377380
try:
381+
await registry.schema.load_schema(db=db, branch=branch)
378382
await rebase_branch(
379383
branch=branch.name,
380384
context=InfrahubContext.init(
381385
branch=branch, account=AccountSession(auth_type=AuthType.NONE, authenticated=False, account_id="")
382386
),
383387
send_events=False,
384388
)
385-
rprint("done")
389+
rprint(SUCCESS_BADGE)
386390
except ValidationError:
387-
rprint("failed")
391+
rprint(FAILED_BADGE)
388392

389393

390394
async def initialize_internal_schema() -> None:

backend/infrahub/core/branch/tasks.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -232,6 +232,7 @@ async def migrate_branch(branch: str, context: InfrahubContext, send_events: boo
232232
await obj.save(db=db)
233233

234234
try:
235+
log.info(f"Running migrations for branch '{obj.name}'")
235236
await migration_runner.run(db=db)
236237
except MigrationFailureError as exc:
237238
log.error(f"Failed to migrate branch '{obj.name}': {exc.errors}")

backend/infrahub/core/migrations/shared.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -237,7 +237,9 @@ async def validate_migration(self, db: InfrahubDatabase) -> MigrationResult:
237237
raise NotImplementedError()
238238

239239
async def execute_against_branch(self, db: InfrahubDatabase, branch: Branch) -> MigrationResult:
240+
"""Method that will be run against non-default branches, it assumes that the branches have been rebased."""
240241
raise NotImplementedError()
241242

242243
async def execute(self, db: InfrahubDatabase) -> MigrationResult:
244+
"""Method that will be run against the default branch."""
243245
raise NotImplementedError()

0 commit comments

Comments
 (0)