infrahub-server 1.2.11__py3-none-any.whl → 1.3.0__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (211) hide show
  1. infrahub/actions/constants.py +130 -0
  2. infrahub/actions/gather.py +114 -0
  3. infrahub/actions/models.py +243 -0
  4. infrahub/actions/parsers.py +104 -0
  5. infrahub/actions/schema.py +393 -0
  6. infrahub/actions/tasks.py +119 -0
  7. infrahub/actions/triggers.py +21 -0
  8. infrahub/branch/__init__.py +0 -0
  9. infrahub/branch/tasks.py +29 -0
  10. infrahub/branch/triggers.py +22 -0
  11. infrahub/cli/db.py +3 -4
  12. infrahub/computed_attribute/gather.py +3 -1
  13. infrahub/computed_attribute/tasks.py +23 -29
  14. infrahub/core/account.py +24 -47
  15. infrahub/core/attribute.py +13 -15
  16. infrahub/core/constants/__init__.py +10 -0
  17. infrahub/core/constants/database.py +1 -0
  18. infrahub/core/constants/infrahubkind.py +9 -0
  19. infrahub/core/constraint/node/runner.py +3 -1
  20. infrahub/core/convert_object_type/__init__.py +0 -0
  21. infrahub/core/convert_object_type/conversion.py +124 -0
  22. infrahub/core/convert_object_type/schema_mapping.py +56 -0
  23. infrahub/core/diff/coordinator.py +8 -1
  24. infrahub/core/diff/query/all_conflicts.py +1 -5
  25. infrahub/core/diff/query/artifact.py +10 -20
  26. infrahub/core/diff/query/delete_query.py +8 -4
  27. infrahub/core/diff/query/diff_get.py +3 -6
  28. infrahub/core/diff/query/field_specifiers.py +1 -1
  29. infrahub/core/diff/query/field_summary.py +2 -4
  30. infrahub/core/diff/query/merge.py +72 -125
  31. infrahub/core/diff/query/save.py +83 -68
  32. infrahub/core/diff/query/summary_counts_enricher.py +34 -54
  33. infrahub/core/diff/query/time_range_query.py +0 -1
  34. infrahub/core/diff/repository/repository.py +4 -0
  35. infrahub/core/graph/__init__.py +1 -1
  36. infrahub/core/manager.py +14 -11
  37. infrahub/core/migrations/graph/__init__.py +6 -0
  38. infrahub/core/migrations/graph/m003_relationship_parent_optional.py +1 -2
  39. infrahub/core/migrations/graph/m012_convert_account_generic.py +1 -1
  40. infrahub/core/migrations/graph/m013_convert_git_password_credential.py +2 -6
  41. infrahub/core/migrations/graph/m015_diff_format_update.py +1 -2
  42. infrahub/core/migrations/graph/m016_diff_delete_bug_fix.py +1 -2
  43. infrahub/core/migrations/graph/m019_restore_rels_to_time.py +11 -22
  44. infrahub/core/migrations/graph/m020_duplicate_edges.py +3 -6
  45. infrahub/core/migrations/graph/m021_missing_hierarchy_merge.py +1 -2
  46. infrahub/core/migrations/graph/m023_deduplicate_cardinality_one_relationships.py +2 -2
  47. infrahub/core/migrations/graph/m024_missing_hierarchy_backfill.py +1 -2
  48. infrahub/core/migrations/graph/m028_delete_diffs.py +1 -2
  49. infrahub/core/migrations/graph/m029_duplicates_cleanup.py +662 -0
  50. infrahub/core/migrations/graph/m030_illegal_edges.py +82 -0
  51. infrahub/core/migrations/query/attribute_add.py +14 -11
  52. infrahub/core/migrations/query/attribute_rename.py +6 -11
  53. infrahub/core/migrations/query/delete_element_in_schema.py +19 -17
  54. infrahub/core/migrations/query/node_duplicate.py +19 -21
  55. infrahub/core/migrations/query/relationship_duplicate.py +19 -18
  56. infrahub/core/migrations/schema/node_attribute_remove.py +4 -8
  57. infrahub/core/migrations/schema/node_remove.py +19 -20
  58. infrahub/core/models.py +29 -2
  59. infrahub/core/node/__init__.py +131 -28
  60. infrahub/core/node/base.py +1 -1
  61. infrahub/core/node/create.py +211 -0
  62. infrahub/core/node/resource_manager/number_pool.py +31 -5
  63. infrahub/core/node/standard.py +6 -1
  64. infrahub/core/path.py +15 -1
  65. infrahub/core/protocols.py +57 -0
  66. infrahub/core/protocols_base.py +3 -0
  67. infrahub/core/query/__init__.py +2 -2
  68. infrahub/core/query/delete.py +3 -3
  69. infrahub/core/query/diff.py +19 -32
  70. infrahub/core/query/ipam.py +10 -20
  71. infrahub/core/query/node.py +29 -47
  72. infrahub/core/query/relationship.py +55 -34
  73. infrahub/core/query/resource_manager.py +1 -2
  74. infrahub/core/query/standard_node.py +19 -5
  75. infrahub/core/query/subquery.py +2 -4
  76. infrahub/core/relationship/constraints/count.py +10 -9
  77. infrahub/core/relationship/constraints/interface.py +2 -1
  78. infrahub/core/relationship/constraints/peer_kind.py +2 -1
  79. infrahub/core/relationship/constraints/peer_parent.py +56 -0
  80. infrahub/core/relationship/constraints/peer_relatives.py +72 -0
  81. infrahub/core/relationship/constraints/profiles_kind.py +1 -1
  82. infrahub/core/relationship/model.py +4 -1
  83. infrahub/core/schema/__init__.py +2 -1
  84. infrahub/core/schema/attribute_parameters.py +160 -0
  85. infrahub/core/schema/attribute_schema.py +130 -7
  86. infrahub/core/schema/basenode_schema.py +27 -3
  87. infrahub/core/schema/definitions/core/__init__.py +29 -1
  88. infrahub/core/schema/definitions/core/group.py +45 -0
  89. infrahub/core/schema/definitions/core/resource_pool.py +9 -0
  90. infrahub/core/schema/definitions/internal.py +43 -5
  91. infrahub/core/schema/generated/attribute_schema.py +16 -3
  92. infrahub/core/schema/generated/relationship_schema.py +11 -1
  93. infrahub/core/schema/manager.py +7 -2
  94. infrahub/core/schema/schema_branch.py +109 -12
  95. infrahub/core/validators/__init__.py +15 -2
  96. infrahub/core/validators/attribute/choices.py +1 -3
  97. infrahub/core/validators/attribute/enum.py +1 -3
  98. infrahub/core/validators/attribute/kind.py +1 -3
  99. infrahub/core/validators/attribute/length.py +13 -7
  100. infrahub/core/validators/attribute/min_max.py +118 -0
  101. infrahub/core/validators/attribute/number_pool.py +106 -0
  102. infrahub/core/validators/attribute/optional.py +1 -4
  103. infrahub/core/validators/attribute/regex.py +5 -6
  104. infrahub/core/validators/attribute/unique.py +1 -3
  105. infrahub/core/validators/determiner.py +18 -2
  106. infrahub/core/validators/enum.py +12 -0
  107. infrahub/core/validators/node/hierarchy.py +3 -6
  108. infrahub/core/validators/query.py +1 -3
  109. infrahub/core/validators/relationship/count.py +6 -12
  110. infrahub/core/validators/relationship/optional.py +2 -4
  111. infrahub/core/validators/relationship/peer.py +177 -12
  112. infrahub/core/validators/tasks.py +1 -1
  113. infrahub/core/validators/uniqueness/query.py +5 -9
  114. infrahub/database/__init__.py +12 -4
  115. infrahub/database/validation.py +100 -0
  116. infrahub/dependencies/builder/constraint/grouped/node_runner.py +4 -0
  117. infrahub/dependencies/builder/constraint/relationship_manager/peer_parent.py +8 -0
  118. infrahub/dependencies/builder/constraint/relationship_manager/peer_relatives.py +8 -0
  119. infrahub/dependencies/builder/constraint/schema/aggregated.py +2 -0
  120. infrahub/dependencies/builder/constraint/schema/relationship_peer.py +8 -0
  121. infrahub/dependencies/builder/diff/deserializer.py +1 -1
  122. infrahub/dependencies/registry.py +4 -0
  123. infrahub/events/group_action.py +1 -0
  124. infrahub/events/models.py +1 -1
  125. infrahub/git/base.py +5 -3
  126. infrahub/git/integrator.py +96 -5
  127. infrahub/git/tasks.py +1 -0
  128. infrahub/graphql/analyzer.py +139 -18
  129. infrahub/graphql/manager.py +4 -0
  130. infrahub/graphql/mutations/action.py +164 -0
  131. infrahub/graphql/mutations/convert_object_type.py +71 -0
  132. infrahub/graphql/mutations/main.py +25 -176
  133. infrahub/graphql/mutations/proposed_change.py +20 -17
  134. infrahub/graphql/mutations/relationship.py +32 -0
  135. infrahub/graphql/mutations/resource_manager.py +63 -7
  136. infrahub/graphql/queries/convert_object_type_mapping.py +34 -0
  137. infrahub/graphql/queries/resource_manager.py +7 -1
  138. infrahub/graphql/resolvers/many_relationship.py +1 -1
  139. infrahub/graphql/resolvers/resolver.py +2 -2
  140. infrahub/graphql/resolvers/single_relationship.py +1 -1
  141. infrahub/graphql/schema.py +6 -0
  142. infrahub/menu/menu.py +34 -2
  143. infrahub/message_bus/messages/__init__.py +0 -10
  144. infrahub/message_bus/operations/__init__.py +0 -8
  145. infrahub/message_bus/operations/refresh/registry.py +4 -7
  146. infrahub/patch/queries/delete_duplicated_edges.py +45 -39
  147. infrahub/pools/models.py +14 -0
  148. infrahub/pools/number.py +5 -3
  149. infrahub/pools/registration.py +22 -0
  150. infrahub/pools/tasks.py +126 -0
  151. infrahub/prefect_server/models.py +1 -19
  152. infrahub/proposed_change/models.py +68 -3
  153. infrahub/proposed_change/tasks.py +911 -34
  154. infrahub/schema/__init__.py +0 -0
  155. infrahub/schema/tasks.py +27 -0
  156. infrahub/schema/triggers.py +23 -0
  157. infrahub/task_manager/models.py +10 -6
  158. infrahub/trigger/catalogue.py +6 -0
  159. infrahub/trigger/models.py +23 -6
  160. infrahub/trigger/setup.py +26 -2
  161. infrahub/trigger/tasks.py +4 -2
  162. infrahub/types.py +6 -0
  163. infrahub/webhook/tasks.py +6 -9
  164. infrahub/workflows/catalogue.py +103 -1
  165. infrahub_sdk/client.py +43 -10
  166. infrahub_sdk/ctl/generator.py +4 -4
  167. infrahub_sdk/ctl/repository.py +1 -1
  168. infrahub_sdk/node/__init__.py +39 -0
  169. infrahub_sdk/node/attribute.py +122 -0
  170. infrahub_sdk/node/constants.py +21 -0
  171. infrahub_sdk/{node.py → node/node.py} +158 -803
  172. infrahub_sdk/node/parsers.py +15 -0
  173. infrahub_sdk/node/property.py +24 -0
  174. infrahub_sdk/node/related_node.py +266 -0
  175. infrahub_sdk/node/relationship.py +302 -0
  176. infrahub_sdk/protocols.py +112 -0
  177. infrahub_sdk/protocols_base.py +34 -2
  178. infrahub_sdk/pytest_plugin/items/python_transform.py +2 -1
  179. infrahub_sdk/query_groups.py +17 -5
  180. infrahub_sdk/schema/main.py +1 -0
  181. infrahub_sdk/schema/repository.py +16 -0
  182. infrahub_sdk/spec/object.py +1 -1
  183. infrahub_sdk/store.py +1 -1
  184. infrahub_sdk/testing/schemas/car_person.py +1 -0
  185. infrahub_sdk/utils.py +7 -20
  186. infrahub_sdk/yaml.py +6 -5
  187. {infrahub_server-1.2.11.dist-info → infrahub_server-1.3.0.dist-info}/METADATA +5 -5
  188. {infrahub_server-1.2.11.dist-info → infrahub_server-1.3.0.dist-info}/RECORD +197 -168
  189. {infrahub_server-1.2.11.dist-info → infrahub_server-1.3.0.dist-info}/WHEEL +1 -1
  190. infrahub_testcontainers/container.py +239 -65
  191. infrahub_testcontainers/docker-compose-cluster.test.yml +321 -0
  192. infrahub_testcontainers/docker-compose.test.yml +2 -1
  193. infrahub_testcontainers/helpers.py +23 -3
  194. infrahub_testcontainers/plugin.py +9 -0
  195. infrahub/message_bus/messages/check_generator_run.py +0 -26
  196. infrahub/message_bus/messages/finalize_validator_execution.py +0 -15
  197. infrahub/message_bus/messages/proposed_change/base_with_diff.py +0 -16
  198. infrahub/message_bus/messages/proposed_change/request_proposedchange_refreshartifacts.py +0 -11
  199. infrahub/message_bus/messages/request_generatordefinition_check.py +0 -20
  200. infrahub/message_bus/messages/request_proposedchange_pipeline.py +0 -23
  201. infrahub/message_bus/operations/check/__init__.py +0 -3
  202. infrahub/message_bus/operations/check/generator.py +0 -156
  203. infrahub/message_bus/operations/finalize/__init__.py +0 -3
  204. infrahub/message_bus/operations/finalize/validator.py +0 -133
  205. infrahub/message_bus/operations/requests/__init__.py +0 -9
  206. infrahub/message_bus/operations/requests/generator_definition.py +0 -140
  207. infrahub/message_bus/operations/requests/proposed_change.py +0 -629
  208. infrahub/patch/queries/consolidate_duplicated_nodes.py +0 -109
  209. /infrahub/{message_bus/messages/proposed_change → actions}/__init__.py +0 -0
  210. {infrahub_server-1.2.11.dist-info → infrahub_server-1.3.0.dist-info}/LICENSE.txt +0 -0
  211. {infrahub_server-1.2.11.dist-info → infrahub_server-1.3.0.dist-info}/entry_points.txt +0 -0
@@ -30,8 +30,7 @@ class EnrichedDiffRootsUpsertQuery(Query):
30
30
  query = """
31
31
  UNWIND $diff_root_list AS diff_root_map
32
32
  WITH diff_root_map
33
- CALL {
34
- WITH diff_root_map
33
+ CALL (diff_root_map) {
35
34
  MERGE (diff_root:DiffRoot {uuid: diff_root_map.uuid})
36
35
  SET diff_root.base_branch = diff_root_map.base_branch
37
36
  SET diff_root.diff_branch = diff_root_map.diff_branch
@@ -43,8 +42,7 @@ CALL {
43
42
  WITH DISTINCT diff_root AS diff_root
44
43
  WITH collect(diff_root) AS diff_roots
45
44
  WHERE SIZE(diff_roots) = 2
46
- CALL {
47
- WITH diff_roots
45
+ CALL (diff_roots) {
48
46
  WITH diff_roots[0] AS base_diff_node, diff_roots[1] AS branch_diff_node
49
47
  MERGE (base_diff_node)-[:DIFF_HAS_PARTNER]-(branch_diff_node)
50
48
  SET (base_diff_node).partner_uuid = (branch_diff_node).uuid
@@ -80,6 +78,7 @@ class EnrichedNodeBatchCreateQuery(Query):
80
78
 
81
79
  async def query_init(self, db: InfrahubDatabase, **kwargs: Any) -> None: # noqa: ARG002
82
80
  self.params = self._build_node_batch_params()
81
+
83
82
  query = """
84
83
  UNWIND $node_details_list AS node_details
85
84
  WITH
@@ -98,7 +97,7 @@ SET
98
97
  diff_node.is_node_kind_migration = node_map.node_properties.is_node_kind_migration,
99
98
  diff_node.path_identifier = node_map.node_properties.path_identifier
100
99
  WITH root_uuid, node_map, diff_node, has_node_conflict
101
- CALL {
100
+ CALL (diff_node) {
102
101
  // -------------------------
103
102
  // delete parent-child relationships for included nodes, they will be added in EnrichedNodesLinkQuery
104
103
  // -------------------------
@@ -107,94 +106,104 @@ CALL {
107
106
  DELETE parent_rel
108
107
  }
109
108
  OPTIONAL MATCH (diff_node)-[:DIFF_HAS_CONFLICT]->(current_node_conflict:DiffConflict)
110
- CALL {
109
+ CALL (diff_node, current_node_conflict, has_node_conflict) {
111
110
  // -------------------------
112
111
  // create a node-level conflict, if necessary
113
112
  // -------------------------
114
113
  WITH diff_node, current_node_conflict, has_node_conflict
115
- WITH diff_node, current_node_conflict, has_node_conflict
116
114
  WHERE current_node_conflict IS NULL AND has_node_conflict = TRUE
117
115
  CREATE (diff_node)-[:DIFF_HAS_CONFLICT]->(:DiffConflict)
118
116
  }
119
- CALL {
117
+ CALL (current_node_conflict, has_node_conflict) {
120
118
  // -------------------------
121
119
  // delete a node-level conflict, if necessary
122
120
  // -------------------------
123
121
  WITH current_node_conflict, has_node_conflict
124
- WITH current_node_conflict, has_node_conflict
125
122
  WHERE current_node_conflict IS NOT NULL AND has_node_conflict = FALSE
126
123
  DETACH DELETE current_node_conflict
127
124
  }
128
125
  WITH root_uuid, node_map, diff_node, has_node_conflict, node_map.conflict_params AS node_conflict_params
129
- CALL {
126
+ CALL (diff_node, has_node_conflict, node_conflict_params) {
130
127
  // -------------------------
131
128
  // set the properties of the node-level conflict, if necessary
132
129
  // -------------------------
133
130
  WITH diff_node, has_node_conflict, node_conflict_params
134
- WITH diff_node, has_node_conflict, node_conflict_params
135
131
  WHERE has_node_conflict = TRUE
136
132
  OPTIONAL MATCH (diff_node)-[:DIFF_HAS_CONFLICT]->(node_conflict:DiffConflict)
137
133
  SET node_conflict = node_conflict_params
138
134
  }
139
- CALL {
140
- // -------------------------
141
- // remove stale attributes for this node
142
- // -------------------------
143
- WITH diff_node, node_map
144
- CALL {
145
- WITH diff_node, node_map
146
- WITH diff_node, %(attr_name_list_comp)s AS attr_names
147
- OPTIONAL MATCH (diff_node)-[:DIFF_HAS_ATTRIBUTE]->(attr_to_delete:DiffAttribute)
148
- WHERE NOT (attr_to_delete.name IN attr_names)
149
- OPTIONAL MATCH (attr_to_delete)-[*..6]->(next_to_delete)
150
- DETACH DELETE next_to_delete
151
- DETACH DELETE attr_to_delete
152
- }
153
- // -------------------------
154
- // add attributes for this node
155
- // -------------------------
135
+ // -------------------------
136
+ // resetting the UNWIND and starting over here reduces memory usage
137
+ // -------------------------
138
+ WITH root_uuid LIMIT 1
139
+ UNWIND $node_details_list AS node_details
140
+ WITH
141
+ node_details.root_uuid AS root_uuid,
142
+ node_details.node_map AS node_map,
143
+ toString(node_details.node_map.node_properties.uuid) AS node_uuid,
144
+ node_details.node_map.node_properties.db_id AS node_db_id
145
+ MATCH (:DiffRoot {uuid: root_uuid})-[:DIFF_HAS_NODE]->(diff_node:DiffNode {uuid: node_uuid, db_id: node_db_id})
146
+ WITH diff_node, node_map, %(attr_name_list_comp)s AS attr_names
147
+ OPTIONAL MATCH (diff_node)-[:DIFF_HAS_ATTRIBUTE]->(attr_to_delete:DiffAttribute)
148
+ WHERE NOT (attr_to_delete.name IN attr_names)
149
+ OPTIONAL MATCH (attr_to_delete)-[*..6]->(next_to_delete)
150
+ DETACH DELETE next_to_delete
151
+ DETACH DELETE attr_to_delete
152
+ // -------------------------
153
+ // add attributes for this node
154
+ // -------------------------
155
+ WITH DISTINCT diff_node, node_map
156
+ CALL (diff_node, node_map) {
156
157
  UNWIND node_map.attributes AS node_attribute
157
158
  MERGE (diff_node)-[:DIFF_HAS_ATTRIBUTE]->(diff_attribute:DiffAttribute {name: node_attribute.node_properties.name})
158
159
  SET diff_attribute = node_attribute.node_properties
159
160
  // -------------------------
160
- // add properties for this attribute
161
+ // remove stale properties for this attribute
161
162
  // -------------------------
162
- WITH diff_attribute, node_attribute
163
+ WITH diff_attribute, node_attribute, %(attr_props_list_comp)s AS prop_types
164
+ OPTIONAL MATCH (diff_attribute)-[:DIFF_HAS_PROPERTY]->(prop_to_delete:DiffProperty)
165
+ WHERE NOT (prop_to_delete.property_type IN prop_types)
166
+ OPTIONAL MATCH (prop_to_delete)-[*..4]->(next_to_delete)
167
+ DETACH DELETE next_to_delete
168
+ DETACH DELETE prop_to_delete
163
169
  // -------------------------
164
- // remove stale properties for this attribute
170
+ // set attribute property values
165
171
  // -------------------------
166
- CALL {
167
- WITH diff_attribute, node_attribute
168
- WITH diff_attribute, %(attr_props_list_comp)s AS prop_types
169
- OPTIONAL MATCH (diff_attribute)-[:DIFF_HAS_PROPERTY]->(prop_to_delete:DiffProperty)
170
- WHERE NOT (prop_to_delete.property_type IN prop_types)
171
- OPTIONAL MATCH (prop_to_delete)-[*..4]->(next_to_delete)
172
- DETACH DELETE next_to_delete
173
- DETACH DELETE prop_to_delete
174
- }
172
+ WITH DISTINCT diff_attribute, node_attribute
175
173
  UNWIND node_attribute.properties AS attr_property
176
174
  MERGE (diff_attribute)-[:DIFF_HAS_PROPERTY]->(diff_attr_prop:DiffProperty {property_type: attr_property.node_properties.property_type})
177
175
  SET diff_attr_prop = attr_property.node_properties
178
- // -------------------------
179
- // add/remove conflict for this property
180
- // -------------------------
181
176
  WITH diff_attr_prop, attr_property
182
177
  OPTIONAL MATCH (diff_attr_prop)-[:DIFF_HAS_CONFLICT]->(current_attr_prop_conflict:DiffConflict)
183
178
  WITH diff_attr_prop, attr_property, current_attr_prop_conflict, (attr_property.conflict_params IS NOT NULL) AS has_prop_conflict
184
- FOREACH (i in CASE WHEN has_prop_conflict = FALSE THEN [1] ELSE [] END |
179
+ CALL (has_prop_conflict, current_attr_prop_conflict) {
180
+ WITH has_prop_conflict, current_attr_prop_conflict
181
+ WHERE has_prop_conflict = FALSE AND current_attr_prop_conflict IS NOT NULL
185
182
  DETACH DELETE current_attr_prop_conflict
186
- )
187
- FOREACH (i in CASE WHEN has_prop_conflict = TRUE THEN [1] ELSE [] END |
183
+ }
184
+ CALL (has_prop_conflict, diff_attr_prop, attr_property) {
185
+ WITH has_prop_conflict
186
+ WHERE has_prop_conflict = TRUE
188
187
  MERGE (diff_attr_prop)-[:DIFF_HAS_CONFLICT]->(diff_attr_prop_conflict:DiffConflict)
189
188
  SET diff_attr_prop_conflict = attr_property.conflict_params
190
- )
189
+ }
191
190
  }
192
191
  // -------------------------
192
+ // resetting the UNWIND and starting over here reduces memory usage
193
+ // -------------------------
194
+ WITH 1 AS resetting LIMIT 1
195
+ UNWIND $node_details_list AS node_details
196
+ WITH
197
+ node_details.root_uuid AS root_uuid,
198
+ node_details.node_map AS node_map,
199
+ toString(node_details.node_map.node_properties.uuid) AS node_uuid,
200
+ node_details.node_map.node_properties.db_id AS node_db_id
201
+ MATCH (:DiffRoot {uuid: root_uuid})-[:DIFF_HAS_NODE]->(diff_node:DiffNode {uuid: node_uuid, db_id: node_db_id})
202
+ // -------------------------
193
203
  // remove stale relationships for this node
194
204
  // -------------------------
195
- CALL {
196
- WITH diff_node, node_map
197
- WITH diff_node, %(rel_name_list_comp)s AS rel_names
205
+ CALL (diff_node, node_map) {
206
+ WITH %(rel_name_list_comp)s AS rel_names
198
207
  OPTIONAL MATCH (diff_node)-[:DIFF_HAS_RELATIONSHIP]->(rel_to_delete:DiffRelationship)
199
208
  WHERE NOT (rel_to_delete.name IN rel_names)
200
209
  OPTIONAL MATCH (rel_to_delete)-[*..8]->(next_to_delete)
@@ -212,9 +221,8 @@ SET diff_relationship = node_relationship.node_properties
212
221
  // remove stale elements for this relationship group
213
222
  // -------------------------
214
223
  WITH diff_relationship, node_relationship
215
- CALL {
216
- WITH diff_relationship, node_relationship
217
- WITH diff_relationship, %(rel_peers_list_comp)s AS rel_peers
224
+ CALL (diff_relationship, node_relationship) {
225
+ WITH %(rel_peers_list_comp)s AS rel_peers
218
226
  OPTIONAL MATCH (diff_relationship)-[:DIFF_HAS_ELEMENT]->(element_to_delete:DiffRelationshipElement)
219
227
  WHERE NOT (element_to_delete.peer_id IN rel_peers)
220
228
  OPTIONAL MATCH (element_to_delete)-[*..6]->(next_to_delete)
@@ -236,20 +244,23 @@ WITH diff_relationship_element, node_single_relationship
236
244
  OPTIONAL MATCH (diff_relationship_element)-[:DIFF_HAS_CONFLICT]->(current_element_conflict:DiffConflict)
237
245
  WITH diff_relationship_element, node_single_relationship, current_element_conflict,
238
246
  (node_single_relationship.conflict_params IS NOT NULL) AS has_element_conflict
239
- FOREACH (i in CASE WHEN has_element_conflict = FALSE THEN [1] ELSE [] END |
247
+ CALL (has_element_conflict, current_element_conflict) {
248
+ WITH has_element_conflict
249
+ WHERE has_element_conflict = FALSE
240
250
  DETACH DELETE current_element_conflict
241
- )
242
- FOREACH (i in CASE WHEN has_element_conflict = TRUE THEN [1] ELSE [] END |
251
+ }
252
+ CALL (has_element_conflict, diff_relationship_element, node_single_relationship) {
253
+ WITH has_element_conflict
254
+ WHERE has_element_conflict = TRUE
243
255
  MERGE (diff_relationship_element)-[:DIFF_HAS_CONFLICT]->(element_conflict:DiffConflict)
244
256
  SET element_conflict = node_single_relationship.conflict_params
245
- )
257
+ }
246
258
  // -------------------------
247
259
  // remove stale properties for this relationship element
248
260
  // -------------------------
249
261
  WITH diff_relationship_element, node_single_relationship
250
- CALL {
251
- WITH diff_relationship_element, node_single_relationship
252
- WITH diff_relationship_element, %(element_props_list_comp)s AS element_props
262
+ CALL (diff_relationship_element, node_single_relationship) {
263
+ WITH %(element_props_list_comp)s AS element_props
253
264
  OPTIONAL MATCH (diff_relationship_element)-[:DIFF_HAS_PROPERTY]->(property_to_delete:DiffProperty)
254
265
  WHERE NOT (property_to_delete.property_type IN element_props)
255
266
  OPTIONAL MATCH (property_to_delete)-[*..4]->(next_to_delete)
@@ -271,13 +282,18 @@ WITH diff_relationship_property, node_relationship_property
271
282
  OPTIONAL MATCH (diff_relationship_property)-[:DIFF_HAS_CONFLICT]->(diff_relationship_property_conflict:DiffConflict)
272
283
  WITH diff_relationship_property, node_relationship_property, diff_relationship_property_conflict,
273
284
  (node_relationship_property.conflict_params IS NOT NULL) AS has_property_conflict
274
- FOREACH (i in CASE WHEN has_property_conflict = FALSE THEN [1] ELSE [] END |
285
+
286
+ CALL (has_property_conflict, diff_relationship_property_conflict) {
287
+ WITH has_property_conflict
288
+ WHERE has_property_conflict = FALSE
275
289
  DETACH DELETE diff_relationship_property_conflict
276
- )
277
- FOREACH (i in CASE WHEN has_property_conflict = TRUE THEN [1] ELSE [] END |
290
+ }
291
+ CALL (has_property_conflict, diff_relationship_property, node_relationship_property) {
292
+ WITH has_property_conflict
293
+ WHERE has_property_conflict = TRUE
278
294
  MERGE (diff_relationship_property)-[:DIFF_HAS_CONFLICT]->(property_conflict:DiffConflict)
279
295
  SET property_conflict = node_relationship_property.conflict_params
280
- )
296
+ }
281
297
  """ % {
282
298
  "attr_name_list_comp": db.render_list_comprehension(
283
299
  items="node_map.attributes", item_name="node_properties.name"
@@ -451,10 +467,9 @@ WITH keys($parent_node_map) AS child_node_uuids
451
467
  MATCH (diff_root:DiffRoot {uuid: $root_uuid})
452
468
  MATCH (diff_root)-[:DIFF_HAS_NODE]->(child_node:DiffNode)
453
469
  WHERE child_node.uuid IN child_node_uuids
454
- CALL {
455
- WITH diff_root, child_node
456
- WITH diff_root, child_node, $parent_node_map[child_node.uuid] AS sub_map
457
- WITH diff_root, child_node, sub_map, keys(sub_map) AS relationship_names
470
+ CALL (diff_root, child_node) {
471
+ WITH $parent_node_map[child_node.uuid] AS sub_map
472
+ WITH sub_map, keys(sub_map) AS relationship_names
458
473
  MATCH (child_node)-[:DIFF_HAS_RELATIONSHIP]->(diff_rel_group:DiffRelationship)
459
474
  WHERE diff_rel_group.name IN relationship_names
460
475
  WITH diff_root, diff_rel_group, toString(sub_map[diff_rel_group.name]) AS parent_uuid
@@ -46,70 +46,59 @@ WHERE ($diff_id IS NOT NULL AND root.uuid = $diff_id)
46
46
  OR ($tracking_id IS NOT NULL AND root.tracking_id = $tracking_id AND root.diff_branch = $diff_branch_name)
47
47
  MATCH (root)-[:DIFF_HAS_NODE]->(dn:DiffNode)
48
48
  WHERE $node_uuids IS NULL OR dn.uuid IN $node_uuids
49
- CALL {
49
+ CALL (dn) {
50
50
  // ----------------------
51
51
  // handle attribute count updates
52
52
  // ----------------------
53
- WITH dn
54
53
  MATCH (dn)-[:DIFF_HAS_ATTRIBUTE]->(da:DiffAttribute)
55
- CALL {
56
- WITH da
54
+ CALL (da) {
57
55
  OPTIONAL MATCH (da)-[:DIFF_HAS_PROPERTY]->(dp:DiffProperty)-[:DIFF_HAS_CONFLICT]->(dc:DiffConflict)
58
- WITH da, count(dc) AS num_conflicts
56
+ WITH count(dc) AS num_conflicts
59
57
  SET da.num_conflicts = num_conflicts
60
58
  SET da.contains_conflict = (num_conflicts > 0)
61
59
  }
62
- CALL {
63
- WITH da
60
+ CALL (da) {
64
61
  OPTIONAL MATCH (da)-[:DIFF_HAS_PROPERTY]->(dp:DiffProperty {action: "added"})
65
- WITH da, count(dp.action) AS num_added
62
+ WITH count(dp.action) AS num_added
66
63
  SET da.num_added = num_added
67
64
  }
68
- CALL {
69
- WITH da
65
+ CALL (da) {
70
66
  OPTIONAL MATCH (da)-[:DIFF_HAS_PROPERTY]->(dp:DiffProperty {action: "updated"})
71
- WITH da, count(dp.action) AS num_updated
67
+ WITH count(dp.action) AS num_updated
72
68
  SET da.num_updated = num_updated
73
69
  }
74
- CALL {
75
- WITH da
70
+ CALL (da) {
76
71
  OPTIONAL MATCH (da)-[:DIFF_HAS_PROPERTY]->(dp:DiffProperty {action: "removed"})
77
- WITH da, count(dp.action) AS num_removed
72
+ WITH count(dp.action) AS num_removed
78
73
  SET da.num_removed = num_removed
79
74
  }
80
75
  }
81
- CALL {
82
- WITH dn
76
+ CALL (dn) {
83
77
  MATCH (dn)-[:DIFF_HAS_RELATIONSHIP]->(dr:DiffRelationship)
84
- CALL {
78
+ CALL (dr) {
85
79
  // ----------------------
86
80
  // handle relationship element count updates
87
81
  // ----------------------
88
- WITH dr
89
82
  MATCH (dr)-[:DIFF_HAS_ELEMENT]->(dre:DiffRelationshipElement)
90
- CALL {
91
- WITH dre
83
+ CALL (dre) {
92
84
  OPTIONAL MATCH (dre)-[*..4]->(dc:DiffConflict)
93
- WITH dre, count(dc) AS num_conflicts
85
+ WITH count(dc) AS num_conflicts
94
86
  SET dre.num_conflicts = num_conflicts
95
87
  SET dre.contains_conflict = (num_conflicts > 0)
96
88
  }
97
- CALL {
98
- WITH dre
89
+ CALL (dre) {
99
90
  OPTIONAL MATCH (dre)-[:DIFF_HAS_PROPERTY]->(dp:DiffProperty {action: "added"})
100
- WITH dre, count(dp.action) AS num_added
91
+ WITH count(dp.action) AS num_added
101
92
  SET dre.num_added = num_added
102
93
  }
103
- CALL {
104
- WITH dre
94
+ CALL (dre) {
105
95
  OPTIONAL MATCH (dre)-[:DIFF_HAS_PROPERTY]->(dp:DiffProperty {action: "updated"})
106
- WITH dre, count(dp.action) AS num_updated
96
+ WITH count(dp.action) AS num_updated
107
97
  SET dre.num_updated = num_updated
108
98
  }
109
- CALL {
110
- WITH dre
99
+ CALL (dre) {
111
100
  OPTIONAL MATCH (dre)-[:DIFF_HAS_PROPERTY]->(dp:DiffProperty {action: "removed"})
112
- WITH dre, count(dp.action) AS num_removed
101
+ WITH count(dp.action) AS num_removed
113
102
  SET dre.num_removed = num_removed
114
103
  }
115
104
  }
@@ -121,22 +110,19 @@ CALL {
121
110
  SET dr.num_conflicts = num_conflicts
122
111
  SET dr.contains_conflict = (num_conflicts > 0)
123
112
  WITH dr
124
- CALL {
125
- WITH dr
113
+ CALL (dr) {
126
114
  OPTIONAL MATCH (dr)-[:DIFF_HAS_ELEMENT]->(dre:DiffRelationshipElement {action: "added"})
127
- WITH dr, count(dre.action) AS num_added
115
+ WITH count(dre.action) AS num_added
128
116
  SET dr.num_added = num_added
129
117
  }
130
- CALL {
131
- WITH dr
118
+ CALL (dr) {
132
119
  OPTIONAL MATCH (dr)-[:DIFF_HAS_ELEMENT]->(dre:DiffRelationshipElement {action: "updated"})
133
- WITH dr, count(dre.action) AS num_updated
120
+ WITH count(dre.action) AS num_updated
134
121
  SET dr.num_updated = num_updated
135
122
  }
136
- CALL {
137
- WITH dr
123
+ CALL (dr) {
138
124
  OPTIONAL MATCH (dr)-[:DIFF_HAS_ELEMENT]->(dre:DiffRelationshipElement {action: "removed"})
139
- WITH dr, count(dre.action) AS num_removed
125
+ WITH count(dre.action) AS num_removed
140
126
  SET dr.num_removed = num_removed
141
127
  }
142
128
  }
@@ -189,19 +175,16 @@ WHERE $node_uuids IS NULL OR dn.uuid IN $node_uuids
189
175
  // handle node count updates
190
176
  // ----------------------
191
177
  WITH root, dn, coalesce(dn.num_conflicts, 0) AS previous_num_conflicts
192
- CALL {
178
+ CALL (dn) {
193
179
  // ----------------------
194
180
  // handle node num_conflicts update
195
181
  // ----------------------
196
- WITH dn
197
182
  OPTIONAL MATCH (dn)-[:DIFF_HAS_ATTRIBUTE]->(da:DiffAttribute {contains_conflict: TRUE})
198
183
  RETURN sum(da.num_conflicts) AS num_conflicts
199
184
  UNION ALL
200
- WITH dn
201
185
  OPTIONAL MATCH (dn)-[:DIFF_HAS_RELATIONSHIP]->(dr:DiffRelationship {contains_conflict: TRUE})
202
186
  RETURN sum(dr.num_conflicts) AS num_conflicts
203
187
  UNION ALL
204
- WITH dn
205
188
  OPTIONAL MATCH (dn)-[:DIFF_HAS_CONFLICT]->(dc:DiffConflict)
206
189
  RETURN count(dc) AS num_conflicts
207
190
  }
@@ -209,17 +192,16 @@ WITH root, dn, previous_num_conflicts, sum(num_conflicts) AS updated_num_conflic
209
192
  SET dn.num_conflicts = updated_num_conflicts
210
193
  SET dn.contains_conflict = (updated_num_conflicts > 0)
211
194
  WITH root, dn, updated_num_conflicts - previous_num_conflicts AS num_conflicts_delta
212
- CALL {
195
+ CALL (dn) {
213
196
  // ----------------------
214
197
  // handle node added/updated/removed updates
215
198
  // ----------------------
216
- WITH dn
217
199
  OPTIONAL MATCH (dn)-[:DIFF_HAS_ATTRIBUTE]->(da:DiffAttribute)
218
- WITH dn, collect(da.action) AS attr_actions
200
+ WITH collect(da.action) AS attr_actions
219
201
  OPTIONAL MATCH (dn)-[:DIFF_HAS_RELATIONSHIP]->(dr:DiffRelationship)
220
- WITH dn, attr_actions, collect(dr.action) AS rel_actions
221
- WITH dn, attr_actions + rel_actions AS actions
222
- WITH dn, reduce(counts = [0,0,0], a IN actions |
202
+ WITH attr_actions, collect(dr.action) AS rel_actions
203
+ WITH attr_actions + rel_actions AS actions
204
+ WITH reduce(counts = [0,0,0], a IN actions |
223
205
  CASE
224
206
  WHEN a = "added" THEN [counts[0] + 1, counts[1], counts[2]]
225
207
  WHEN a = "updated" THEN [counts[0], counts[1] + 1, counts[2]]
@@ -227,7 +209,7 @@ CALL {
227
209
  ELSE counts
228
210
  END
229
211
  ) AS action_counts
230
- WITH dn, action_counts[0] AS num_added, action_counts[1] AS num_updated, action_counts[2] AS num_removed
212
+ WITH action_counts[0] AS num_added, action_counts[1] AS num_updated, action_counts[2] AS num_removed
231
213
  SET dn.num_added = num_added
232
214
  SET dn.num_updated = num_updated
233
215
  SET dn.num_removed = num_removed
@@ -236,8 +218,7 @@ CALL {
236
218
  // handle conflict updates for parent nodes
237
219
  // ----------------------
238
220
  WITH root, dn, num_conflicts_delta
239
- CALL {
240
- WITH dn, num_conflicts_delta
221
+ CALL (dn, num_conflicts_delta) {
241
222
  OPTIONAL MATCH (dn)-[:DIFF_HAS_RELATIONSHIP|DIFF_HAS_NODE*1..]->(parent_node:DiffNode)
242
223
  SET parent_node.num_conflicts = parent_node.num_conflicts + num_conflicts_delta
243
224
  SET parent_node.contains_conflict = (parent_node.num_conflicts > 0)
@@ -246,8 +227,7 @@ CALL {
246
227
  // handle root count updates
247
228
  // ----------------------
248
229
  WITH root, sum(num_conflicts_delta) AS total_conflicts_delta
249
- CALL {
250
- WITH root, total_conflicts_delta
230
+ CALL (root, total_conflicts_delta) {
251
231
  SET root.num_conflicts = coalesce(root.num_conflicts, 0) + total_conflicts_delta
252
232
  SET root.contains_conflict = root.num_conflicts > 0
253
233
  WITH root
@@ -37,7 +37,6 @@ class EnrichedDiffTimeRangeQuery(Query):
37
37
  "from_time": self.from_time.to_string(),
38
38
  "to_time": self.to_time.to_string(),
39
39
  }
40
- # ruff: noqa: E501
41
40
  query = """
42
41
  // get the roots of all diffs in the query
43
42
  MATCH (diff_root:DiffRoot)
@@ -377,6 +377,10 @@ class DiffRepository:
377
377
  await query.execute(db=self.db)
378
378
  return query.get_summary()
379
379
 
380
+ async def delete_all_diff_roots(self) -> None:
381
+ query = await EnrichedDiffDeleteQuery.init(db=self.db)
382
+ await query.execute(db=self.db)
383
+
380
384
  async def delete_diff_roots(self, diff_root_uuids: list[str]) -> None:
381
385
  query = await EnrichedDiffDeleteQuery.init(db=self.db, enriched_diff_root_uuids=diff_root_uuids)
382
386
  await query.execute(db=self.db)
@@ -1 +1 @@
1
- GRAPH_VERSION = 28
1
+ GRAPH_VERSION = 30
infrahub/core/manager.py CHANGED
@@ -1,5 +1,6 @@
1
1
  from __future__ import annotations
2
2
 
3
+ from copy import copy
3
4
  from functools import reduce
4
5
  from typing import TYPE_CHECKING, Any, Iterable, Literal, TypeVar, overload
5
6
 
@@ -1339,22 +1340,24 @@ class NodeManager:
1339
1340
  nodes: list[Node],
1340
1341
  branch: Branch | str | None = None,
1341
1342
  at: Timestamp | str | None = None,
1343
+ cascade_delete: bool = True,
1342
1344
  ) -> list[Node]:
1343
1345
  """Returns list of deleted nodes because of cascading deletes"""
1344
1346
  branch = await registry.get_branch(branch=branch, db=db)
1345
- node_delete_validator = NodeDeleteValidator(db=db, branch=branch)
1346
- ids_to_delete = await node_delete_validator.get_ids_to_delete(nodes=nodes, at=at)
1347
- node_ids = {node.get_id() for node in nodes}
1348
- missing_ids_to_delete = ids_to_delete - node_ids
1349
- if missing_ids_to_delete:
1350
- node_map = await cls.get_many(db=db, ids=list(missing_ids_to_delete), branch=branch, at=at)
1351
- nodes += list(node_map.values())
1352
- deleted_nodes = []
1353
- for node in nodes:
1347
+ nodes_to_delete = copy(nodes)
1348
+ if cascade_delete:
1349
+ node_delete_validator = NodeDeleteValidator(db=db, branch=branch)
1350
+ ids_to_delete = await node_delete_validator.get_ids_to_delete(nodes=nodes, at=at)
1351
+ node_ids = {node.get_id() for node in nodes}
1352
+ missing_ids_to_delete = ids_to_delete - node_ids
1353
+ if missing_ids_to_delete:
1354
+ node_map = await cls.get_many(db=db, ids=list(missing_ids_to_delete), branch=branch, at=at)
1355
+ nodes_to_delete += list(node_map.values())
1356
+
1357
+ for node in nodes_to_delete:
1354
1358
  await node.delete(db=db, at=at)
1355
- deleted_nodes.append(node)
1356
1359
 
1357
- return deleted_nodes
1360
+ return nodes_to_delete
1358
1361
 
1359
1362
 
1360
1363
  def _get_cardinality_one_identifiers_by_kind(
@@ -29,6 +29,9 @@ from .m024_missing_hierarchy_backfill import Migration024
29
29
  from .m025_uniqueness_nulls import Migration025
30
30
  from .m026_0000_prefix_fix import Migration026
31
31
  from .m027_delete_isolated_nodes import Migration027
32
+ from .m028_delete_diffs import Migration028
33
+ from .m029_duplicates_cleanup import Migration029
34
+ from .m030_illegal_edges import Migration030
32
35
 
33
36
  if TYPE_CHECKING:
34
37
  from infrahub.core.root import Root
@@ -63,6 +66,9 @@ MIGRATIONS: list[type[GraphMigration | InternalSchemaMigration | ArbitraryMigrat
63
66
  Migration025,
64
67
  Migration026,
65
68
  Migration027,
69
+ Migration028,
70
+ Migration029,
71
+ Migration030,
66
72
  ]
67
73
 
68
74
 
@@ -26,8 +26,7 @@ class Migration003Query01(Query):
26
26
  query = """
27
27
  MATCH path = (av2:AttributeValue)-[:HAS_VALUE]-(:Attribute {name: "optional"})-[:HAS_ATTRIBUTE]-(n:SchemaRelationship)-[:HAS_ATTRIBUTE]-(:Attribute {name: "kind"})-[:HAS_VALUE]-(av1:AttributeValue)
28
28
  WHERE av1.value = "Parent" AND av2.value = true AND all(r IN relationships(path) WHERE ( %(filters)s ))
29
- CALL {
30
- WITH n
29
+ CALL (n) {
31
30
  MATCH path22 = (av22:AttributeValue)-[r22:HAS_VALUE]-(a2:Attribute {name: "optional"})-[:HAS_ATTRIBUTE]-(n:SchemaRelationship)-[:HAS_ATTRIBUTE]-(:Attribute {name:"kind"})-[:HAS_VALUE]-(av11:AttributeValue)
32
31
  WHERE av11.value = "Parent" AND av22.value = true AND all(r IN relationships(path22) WHERE ( %(filters)s ))
33
32
  RETURN av22 as av2_sub, r22, a2, path22 as path2
@@ -61,7 +61,7 @@ class Migration012RenameTypeAttributeData(AttributeRenameQuery):
61
61
  def render_match(self) -> str:
62
62
  query = """
63
63
  // Find all the active nodes
64
- CALL {
64
+ CALL () {
65
65
  MATCH (node:%(node_kind)s)
66
66
  WHERE exists((node)-[:HAS_ATTRIBUTE]-(:Attribute { name: $prev_attr.name }))
67
67
  AND NOT exists((node)-[:HAS_ATTRIBUTE]-(:Attribute { name: $new_attr.name }))
@@ -77,7 +77,6 @@ class Migration013ConvertCoreRepositoryWithCred(Query):
77
77
 
78
78
  self.params["rel_identifier"] = "gitrepository__credential"
79
79
 
80
- # ruff: noqa: E501
81
80
  query = """
82
81
  // --------------------------------
83
82
  // Identify the git repositories to convert
@@ -98,8 +97,7 @@ class Migration013ConvertCoreRepositoryWithCred(Query):
98
97
  // --------------------------------
99
98
  MATCH (git_repo)-[:HAS_ATTRIBUTE]-(git_attr_name:Attribute)-[:HAS_VALUE]->(git_name_value:AttributeValue)
100
99
  WHERE git_attr_name.name = "name"
101
- CALL {
102
- WITH git_repo
100
+ CALL (git_repo) {
103
101
  MATCH path1 = (git_repo)-[r1:HAS_ATTRIBUTE]-(git_attr_name2:Attribute)-[r2:HAS_VALUE]->(git_name_value2:AttributeValue)
104
102
  WHERE git_attr_name2.name = "name"
105
103
  AND all(r IN relationships(path1) WHERE %(filters)s)
@@ -195,7 +193,6 @@ class Migration013ConvertCoreRepositoryWithoutCred(Query):
195
193
 
196
194
  self.params["current_time"] = self.at.to_string()
197
195
 
198
- # ruff: noqa: E501
199
196
  query = """
200
197
  // --------------------------------
201
198
  // Identify the git repositories to convert
@@ -204,8 +201,7 @@ class Migration013ConvertCoreRepositoryWithoutCred(Query):
204
201
  WHERE a.name in ["username", "password"]
205
202
  AND av.value = "NULL"
206
203
  AND all(r IN relationships(path) WHERE %(filters)s AND r.status = "active")
207
- CALL {
208
- WITH node
204
+ CALL (node) {
209
205
  MATCH (root:Root)<-[r:IS_PART_OF]-(node)
210
206
  WHERE %(filters)s
211
207
  RETURN node as n1, r as r1
@@ -31,6 +31,5 @@ class Migration015(ArbitraryMigration):
31
31
  component_registry = get_component_registry()
32
32
  diff_repo = await component_registry.get_component(DiffRepository, db=db, branch=default_branch)
33
33
 
34
- diff_roots = await diff_repo.get_roots_metadata()
35
- await diff_repo.delete_diff_roots(diff_root_uuids=[d.uuid for d in diff_roots])
34
+ await diff_repo.delete_all_diff_roots()
36
35
  return MigrationResult()
@@ -31,6 +31,5 @@ class Migration016(ArbitraryMigration):
31
31
  component_registry = get_component_registry()
32
32
  diff_repo = await component_registry.get_component(DiffRepository, db=db, branch=default_branch)
33
33
 
34
- diff_roots = await diff_repo.get_roots_metadata()
35
- await diff_repo.delete_diff_roots(diff_root_uuids=[d.uuid for d in diff_roots])
34
+ await diff_repo.delete_all_diff_roots()
36
35
  return MigrationResult()