MCPcopy Index your code
hub / github.com/tortoise/tortoise-orm / _backward_plan

Method _backward_plan

tortoise/migrations/executor.py:321–340  ·  view source on GitHub ↗
(
        self,
        target: MigrationTarget,
        applied: set[MigrationKey],
        graph: MigrationGraph,
        *,
        include_target: bool = False,
    )

Source from the content-addressed store, hash-verified

319 return plan
320
321 def _backward_plan(
322 self,
323 target: MigrationTarget,
324 applied: set[MigrationKey],
325 graph: MigrationGraph,
326 *,
327 include_target: bool = False,
328 ) -> list[PlanStep]:
329 plan: list[PlanStep] = []
330 target_key = MigrationKey(app_label=target.app_label, name=target.name)
331 for key in graph.backwards_plan(target_key):
332 if key not in applied:
333 continue
334 if not include_target and key == target_key:
335 continue
336 migration = graph.nodes[key]
337 if not isinstance(migration, Migration):
338 raise ValueError(f"Missing migration for {key}")
339 plan.append(PlanStep(migration=migration, backward=True))
340 return plan
341
342 def _dedupe_plan(self, plan: list[PlanStep]) -> list[PlanStep]:
343 deduped: list[PlanStep] = []

Callers 1

_migration_planMethod · 0.95

Calls 3

MigrationKeyClass · 0.90
PlanStepClass · 0.85
backwards_planMethod · 0.80

Tested by

no test coverage detected