| 81 | self.nodes[key] = None |
| 82 | |
| 83 | def add_dependency( |
| 84 | self, |
| 85 | migration: MigrationKey, |
| 86 | child: MigrationKey, |
| 87 | parent: MigrationKey, |
| 88 | *, |
| 89 | skip_validation: bool = False, |
| 90 | ) -> None: |
| 91 | if child not in self.nodes: |
| 92 | self.add_dummy_node( |
| 93 | child, |
| 94 | migration, |
| 95 | f"Migration {migration} references nonexistent child {child}", |
| 96 | ) |
| 97 | if parent not in self.nodes: |
| 98 | self.add_dummy_node( |
| 99 | parent, |
| 100 | migration, |
| 101 | f"Migration {migration} references nonexistent parent {parent}", |
| 102 | ) |
| 103 | self.node_map[child].add_parent(self.node_map[parent]) |
| 104 | self.node_map[parent].add_child(self.node_map[child]) |
| 105 | if not skip_validation: |
| 106 | self.validate_consistency() |
| 107 | |
| 108 | def validate_consistency(self) -> None: |
| 109 | for node in self.node_map.values(): |