Skip to content

Commit b73057b

Browse files
committed
Fix rebase of branches using upgrade command
1 parent cd6a1a0 commit b73057b

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
@@ -239,7 +239,9 @@ async def validate_migration(self, db: InfrahubDatabase) -> MigrationResult:
239239
raise NotImplementedError()
240240

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

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

0 commit comments

Comments
 (0)