infrahub-server 1.7.0b0__py3-none-any.whl → 1.7.1__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 (177) hide show
  1. infrahub/api/exceptions.py +2 -2
  2. infrahub/api/schema.py +5 -0
  3. infrahub/cli/db.py +54 -24
  4. infrahub/core/account.py +12 -9
  5. infrahub/core/branch/models.py +11 -117
  6. infrahub/core/branch/tasks.py +7 -3
  7. infrahub/core/diff/branch_differ.py +1 -1
  8. infrahub/core/diff/conflict_transferer.py +1 -1
  9. infrahub/core/diff/data_check_synchronizer.py +1 -1
  10. infrahub/core/diff/enricher/cardinality_one.py +1 -1
  11. infrahub/core/diff/enricher/hierarchy.py +1 -1
  12. infrahub/core/diff/enricher/labels.py +1 -1
  13. infrahub/core/diff/merger/merger.py +6 -2
  14. infrahub/core/diff/repository/repository.py +3 -1
  15. infrahub/core/graph/__init__.py +1 -1
  16. infrahub/core/graph/constraints.py +1 -1
  17. infrahub/core/initialization.py +2 -1
  18. infrahub/core/ipam/reconciler.py +8 -6
  19. infrahub/core/ipam/utilization.py +8 -15
  20. infrahub/core/manager.py +1 -26
  21. infrahub/core/merge.py +1 -1
  22. infrahub/core/migrations/graph/__init__.py +2 -0
  23. infrahub/core/migrations/graph/m012_convert_account_generic.py +12 -12
  24. infrahub/core/migrations/graph/m013_convert_git_password_credential.py +4 -4
  25. infrahub/core/migrations/graph/m014_remove_index_attr_value.py +3 -2
  26. infrahub/core/migrations/graph/m015_diff_format_update.py +3 -2
  27. infrahub/core/migrations/graph/m016_diff_delete_bug_fix.py +3 -2
  28. infrahub/core/migrations/graph/m017_add_core_profile.py +6 -4
  29. infrahub/core/migrations/graph/m018_uniqueness_nulls.py +3 -4
  30. infrahub/core/migrations/graph/m020_duplicate_edges.py +3 -3
  31. infrahub/core/migrations/graph/m025_uniqueness_nulls.py +3 -4
  32. infrahub/core/migrations/graph/m026_0000_prefix_fix.py +4 -5
  33. infrahub/core/migrations/graph/m028_delete_diffs.py +3 -2
  34. infrahub/core/migrations/graph/m029_duplicates_cleanup.py +3 -2
  35. infrahub/core/migrations/graph/m031_check_number_attributes.py +4 -3
  36. infrahub/core/migrations/graph/m032_cleanup_orphaned_branch_relationships.py +3 -2
  37. infrahub/core/migrations/graph/m034_find_orphaned_schema_fields.py +3 -2
  38. infrahub/core/migrations/graph/m035_orphan_relationships.py +3 -3
  39. infrahub/core/migrations/graph/m036_drop_attr_value_index.py +3 -2
  40. infrahub/core/migrations/graph/m037_index_attr_vals.py +3 -2
  41. infrahub/core/migrations/graph/m038_redo_0000_prefix_fix.py +4 -5
  42. infrahub/core/migrations/graph/m039_ipam_reconcile.py +3 -2
  43. infrahub/core/migrations/graph/m041_deleted_dup_edges.py +4 -3
  44. infrahub/core/migrations/graph/m042_profile_attrs_in_db.py +5 -4
  45. infrahub/core/migrations/graph/m043_create_hfid_display_label_in_db.py +12 -5
  46. infrahub/core/migrations/graph/m044_backfill_hfid_display_label_in_db.py +15 -4
  47. infrahub/core/migrations/graph/m045_backfill_hfid_display_label_in_db_profile_template.py +10 -4
  48. infrahub/core/migrations/graph/m046_fill_agnostic_hfid_display_labels.py +6 -5
  49. infrahub/core/migrations/graph/m047_backfill_or_null_display_label.py +19 -5
  50. infrahub/core/migrations/graph/m048_undelete_rel_props.py +6 -4
  51. infrahub/core/migrations/graph/m049_remove_is_visible_relationship.py +19 -4
  52. infrahub/core/migrations/graph/m050_backfill_vertex_metadata.py +3 -3
  53. infrahub/core/migrations/graph/m051_subtract_branched_from_microsecond.py +39 -0
  54. infrahub/core/migrations/query/__init__.py +2 -2
  55. infrahub/core/migrations/query/schema_attribute_update.py +1 -1
  56. infrahub/core/migrations/runner.py +6 -3
  57. infrahub/core/migrations/schema/attribute_kind_update.py +8 -11
  58. infrahub/core/migrations/schema/attribute_name_update.py +1 -1
  59. infrahub/core/migrations/schema/attribute_supports_profile.py +5 -10
  60. infrahub/core/migrations/schema/models.py +8 -0
  61. infrahub/core/migrations/schema/node_attribute_add.py +11 -14
  62. infrahub/core/migrations/schema/node_attribute_remove.py +1 -1
  63. infrahub/core/migrations/schema/node_kind_update.py +1 -1
  64. infrahub/core/migrations/schema/tasks.py +7 -1
  65. infrahub/core/migrations/shared.py +37 -30
  66. infrahub/core/node/__init__.py +3 -2
  67. infrahub/core/node/base.py +9 -5
  68. infrahub/core/node/delete_validator.py +1 -1
  69. infrahub/core/order.py +30 -0
  70. infrahub/core/protocols.py +1 -0
  71. infrahub/core/protocols_base.py +4 -0
  72. infrahub/core/query/__init__.py +8 -5
  73. infrahub/core/query/attribute.py +3 -3
  74. infrahub/core/query/branch.py +1 -1
  75. infrahub/core/query/delete.py +1 -1
  76. infrahub/core/query/diff.py +3 -3
  77. infrahub/core/query/ipam.py +104 -43
  78. infrahub/core/query/node.py +454 -101
  79. infrahub/core/query/relationship.py +83 -26
  80. infrahub/core/query/resource_manager.py +107 -18
  81. infrahub/core/relationship/constraints/count.py +1 -1
  82. infrahub/core/relationship/constraints/peer_kind.py +1 -1
  83. infrahub/core/relationship/constraints/peer_parent.py +1 -1
  84. infrahub/core/relationship/constraints/peer_relatives.py +1 -1
  85. infrahub/core/relationship/constraints/profiles_kind.py +1 -1
  86. infrahub/core/relationship/constraints/profiles_removal.py +1 -1
  87. infrahub/core/relationship/model.py +8 -2
  88. infrahub/core/schema/attribute_parameters.py +28 -1
  89. infrahub/core/schema/attribute_schema.py +9 -15
  90. infrahub/core/schema/basenode_schema.py +3 -0
  91. infrahub/core/schema/definitions/core/__init__.py +8 -2
  92. infrahub/core/schema/definitions/core/account.py +10 -10
  93. infrahub/core/schema/definitions/core/artifact.py +14 -8
  94. infrahub/core/schema/definitions/core/check.py +10 -4
  95. infrahub/core/schema/definitions/core/generator.py +26 -6
  96. infrahub/core/schema/definitions/core/graphql_query.py +1 -1
  97. infrahub/core/schema/definitions/core/group.py +9 -2
  98. infrahub/core/schema/definitions/core/ipam.py +80 -10
  99. infrahub/core/schema/definitions/core/menu.py +41 -7
  100. infrahub/core/schema/definitions/core/permission.py +16 -2
  101. infrahub/core/schema/definitions/core/profile.py +16 -2
  102. infrahub/core/schema/definitions/core/propose_change.py +24 -4
  103. infrahub/core/schema/definitions/core/propose_change_comment.py +23 -11
  104. infrahub/core/schema/definitions/core/propose_change_validator.py +50 -21
  105. infrahub/core/schema/definitions/core/repository.py +10 -0
  106. infrahub/core/schema/definitions/core/resource_pool.py +8 -1
  107. infrahub/core/schema/definitions/core/template.py +19 -2
  108. infrahub/core/schema/definitions/core/transform.py +11 -5
  109. infrahub/core/schema/definitions/core/webhook.py +27 -9
  110. infrahub/core/schema/manager.py +50 -38
  111. infrahub/core/schema/schema_branch.py +68 -2
  112. infrahub/core/utils.py +3 -3
  113. infrahub/core/validators/aggregated_checker.py +1 -1
  114. infrahub/core/validators/attribute/choices.py +1 -1
  115. infrahub/core/validators/attribute/enum.py +1 -1
  116. infrahub/core/validators/attribute/kind.py +6 -3
  117. infrahub/core/validators/attribute/length.py +1 -1
  118. infrahub/core/validators/attribute/min_max.py +1 -1
  119. infrahub/core/validators/attribute/number_pool.py +1 -1
  120. infrahub/core/validators/attribute/optional.py +1 -1
  121. infrahub/core/validators/attribute/regex.py +1 -1
  122. infrahub/core/validators/node/attribute.py +1 -1
  123. infrahub/core/validators/node/relationship.py +1 -1
  124. infrahub/core/validators/relationship/peer.py +1 -1
  125. infrahub/database/__init__.py +1 -1
  126. infrahub/git/utils.py +1 -1
  127. infrahub/graphql/app.py +2 -2
  128. infrahub/graphql/field_extractor.py +1 -1
  129. infrahub/graphql/manager.py +17 -3
  130. infrahub/graphql/mutations/account.py +1 -1
  131. infrahub/graphql/order.py +14 -0
  132. infrahub/graphql/queries/diff/tree.py +5 -5
  133. infrahub/graphql/queries/resource_manager.py +25 -24
  134. infrahub/graphql/resolvers/ipam.py +3 -3
  135. infrahub/graphql/resolvers/resolver.py +44 -3
  136. infrahub/graphql/types/standard_node.py +8 -4
  137. infrahub/lock.py +7 -0
  138. infrahub/menu/repository.py +1 -1
  139. infrahub/patch/queries/base.py +1 -1
  140. infrahub/pools/number.py +1 -8
  141. infrahub/profiles/node_applier.py +1 -1
  142. infrahub/profiles/queries/get_profile_data.py +1 -1
  143. infrahub/proposed_change/action_checker.py +1 -1
  144. infrahub/services/__init__.py +1 -1
  145. infrahub/services/adapters/cache/nats.py +1 -1
  146. infrahub/services/adapters/cache/redis.py +7 -0
  147. infrahub/webhook/gather.py +1 -1
  148. infrahub/webhook/tasks.py +22 -6
  149. infrahub_sdk/analyzer.py +2 -2
  150. infrahub_sdk/branch.py +12 -39
  151. infrahub_sdk/checks.py +4 -4
  152. infrahub_sdk/client.py +36 -0
  153. infrahub_sdk/ctl/cli_commands.py +2 -1
  154. infrahub_sdk/ctl/graphql.py +15 -4
  155. infrahub_sdk/ctl/utils.py +2 -2
  156. infrahub_sdk/enums.py +6 -0
  157. infrahub_sdk/graphql/renderers.py +21 -0
  158. infrahub_sdk/graphql/utils.py +85 -0
  159. infrahub_sdk/node/attribute.py +12 -2
  160. infrahub_sdk/node/constants.py +11 -0
  161. infrahub_sdk/node/metadata.py +69 -0
  162. infrahub_sdk/node/node.py +65 -14
  163. infrahub_sdk/node/property.py +3 -0
  164. infrahub_sdk/node/related_node.py +24 -1
  165. infrahub_sdk/node/relationship.py +10 -1
  166. infrahub_sdk/operation.py +2 -2
  167. infrahub_sdk/schema/repository.py +1 -2
  168. infrahub_sdk/transforms.py +2 -2
  169. infrahub_sdk/types.py +18 -2
  170. {infrahub_server-1.7.0b0.dist-info → infrahub_server-1.7.1.dist-info}/METADATA +6 -6
  171. {infrahub_server-1.7.0b0.dist-info → infrahub_server-1.7.1.dist-info}/RECORD +176 -172
  172. {infrahub_server-1.7.0b0.dist-info → infrahub_server-1.7.1.dist-info}/entry_points.txt +0 -1
  173. infrahub_testcontainers/models.py +3 -3
  174. infrahub_testcontainers/performance_test.py +1 -1
  175. infrahub/graphql/models.py +0 -36
  176. {infrahub_server-1.7.0b0.dist-info → infrahub_server-1.7.1.dist-info}/WHEEL +0 -0
  177. {infrahub_server-1.7.0b0.dist-info → infrahub_server-1.7.1.dist-info}/licenses/LICENSE.txt +0 -0
@@ -40,25 +40,18 @@ class PrefixUtilizationGetter:
40
40
  )
41
41
  await query.execute(db=self.db)
42
42
 
43
- for result in query.get_results():
44
- prefix_node = result.get_node("pfx")
45
- prefix_id = str(prefix_node.get("uuid"))
46
- branch_name = str(result.get("branch"))
47
- child_node = result.get_node("child")
48
- if InfrahubKind.IPADDRESS in child_node.labels:
43
+ for item in query.get_data():
44
+ if InfrahubKind.IPADDRESS in item.child_labels:
49
45
  child_type = PrefixMemberType.ADDRESS
50
46
  else:
51
47
  child_type = PrefixMemberType.PREFIX
52
- child_value_node = result.get_node("av")
53
- child_prefixlen = child_value_node.get("prefixlen")
54
- child_ip_value = child_value_node.get("value")
55
48
 
56
- if prefix_id not in self._results_by_prefix_id:
57
- self._results_by_prefix_id[prefix_id] = {}
58
- if branch_name not in self._results_by_prefix_id[prefix_id]:
59
- self._results_by_prefix_id[prefix_id][branch_name] = []
60
- self._results_by_prefix_id[prefix_id][branch_name].append(
61
- PrefixChildDetails(child_type=child_type, prefixlen=child_prefixlen, ip_value=child_ip_value)
49
+ if item.prefix_uuid not in self._results_by_prefix_id:
50
+ self._results_by_prefix_id[item.prefix_uuid] = {}
51
+ if item.branch not in self._results_by_prefix_id[item.prefix_uuid]:
52
+ self._results_by_prefix_id[item.prefix_uuid][item.branch] = []
53
+ self._results_by_prefix_id[item.prefix_uuid][item.branch].append(
54
+ PrefixChildDetails(child_type=child_type, prefixlen=item.prefixlen, ip_value=item.ip_value)
62
55
  )
63
56
 
64
57
  async def get_children(
infrahub/core/manager.py CHANGED
@@ -15,6 +15,7 @@ from infrahub.core.constants import (
15
15
  from infrahub.core.metadata.model import MetadataQueryOptions
16
16
  from infrahub.core.node import Node
17
17
  from infrahub.core.node.delete_validator import NodeDeleteValidator
18
+ from infrahub.core.order import OrderModel
18
19
  from infrahub.core.query.node import (
19
20
  AttributeFromDB,
20
21
  GroupedPeerNodes,
@@ -39,7 +40,6 @@ from infrahub.core.schema import (
39
40
  )
40
41
  from infrahub.core.timestamp import Timestamp
41
42
  from infrahub.exceptions import NodeNotFoundError, ProcessingError, SchemaNotFoundError
42
- from infrahub.graphql.models import OrderModel
43
43
 
44
44
  if TYPE_CHECKING:
45
45
  from infrahub.core.branch import Branch
@@ -98,7 +98,6 @@ class NodeManager:
98
98
  branch: Branch | str | None = ...,
99
99
  include_metadata: MetadataQueryOptions | MetadataOptions = ...,
100
100
  prefetch_relationships: bool = ...,
101
- account=...,
102
101
  partial_match: bool = ...,
103
102
  branch_agnostic: bool = ...,
104
103
  order: OrderModel | None = ...,
@@ -118,7 +117,6 @@ class NodeManager:
118
117
  branch: Branch | str | None = ...,
119
118
  include_metadata: MetadataQueryOptions | MetadataOptions = ...,
120
119
  prefetch_relationships: bool = ...,
121
- account=...,
122
120
  partial_match: bool = ...,
123
121
  branch_agnostic: bool = ...,
124
122
  order: OrderModel | None = ...,
@@ -137,7 +135,6 @@ class NodeManager:
137
135
  branch: Branch | str | None = None,
138
136
  include_metadata: MetadataQueryOptions | MetadataOptions = MetadataOptions.NONE,
139
137
  prefetch_relationships: bool = False,
140
- account=None,
141
138
  partial_match: bool = False,
142
139
  branch_agnostic: bool = False,
143
140
  order: OrderModel | None = None,
@@ -171,7 +168,6 @@ class NodeManager:
171
168
  branch=branch,
172
169
  include_metadata=include_metadata,
173
170
  prefetch_relationships=prefetch_relationships,
174
- account=account,
175
171
  branch_agnostic=branch_agnostic,
176
172
  )
177
173
  return [node] if node else []
@@ -230,7 +226,6 @@ class NodeManager:
230
226
  filters: dict | None = None,
231
227
  at: Timestamp | str | None = None,
232
228
  branch: Branch | str | None = None,
233
- account=None, # noqa: ARG003
234
229
  partial_match: bool = False,
235
230
  branch_agnostic: bool = False,
236
231
  ) -> int:
@@ -534,7 +529,6 @@ class NodeManager:
534
529
  branch: Branch | str | None = ...,
535
530
  include_metadata: MetadataQueryOptions | MetadataOptions = ...,
536
531
  prefetch_relationships: bool = ...,
537
- account=...,
538
532
  branch_agnostic: bool = ...,
539
533
  ) -> SchemaProtocol | None: ...
540
534
 
@@ -551,7 +545,6 @@ class NodeManager:
551
545
  branch: Branch | str | None = ...,
552
546
  include_metadata: MetadataQueryOptions | MetadataOptions = ...,
553
547
  prefetch_relationships: bool = ...,
554
- account=...,
555
548
  branch_agnostic: bool = ...,
556
549
  ) -> SchemaProtocol: ...
557
550
 
@@ -568,7 +561,6 @@ class NodeManager:
568
561
  branch: Branch | str | None = ...,
569
562
  include_metadata: MetadataQueryOptions | MetadataOptions = ...,
570
563
  prefetch_relationships: bool = ...,
571
- account=...,
572
564
  branch_agnostic: bool = ...,
573
565
  ) -> SchemaProtocol | None: ...
574
566
 
@@ -585,7 +577,6 @@ class NodeManager:
585
577
  branch: Branch | str | None = ...,
586
578
  include_metadata: MetadataQueryOptions | MetadataOptions = ...,
587
579
  prefetch_relationships: bool = ...,
588
- account=...,
589
580
  branch_agnostic: bool = ...,
590
581
  ) -> Node | None: ...
591
582
 
@@ -602,7 +593,6 @@ class NodeManager:
602
593
  branch: Branch | str | None = ...,
603
594
  include_metadata: MetadataQueryOptions | MetadataOptions = ...,
604
595
  prefetch_relationships: bool = ...,
605
- account=...,
606
596
  branch_agnostic: bool = ...,
607
597
  ) -> Node: ...
608
598
 
@@ -619,7 +609,6 @@ class NodeManager:
619
609
  branch: Branch | str | None = ...,
620
610
  include_metadata: MetadataQueryOptions | MetadataOptions = ...,
621
611
  prefetch_relationships: bool = ...,
622
- account=...,
623
612
  branch_agnostic: bool = ...,
624
613
  ) -> Node | None: ...
625
614
 
@@ -635,7 +624,6 @@ class NodeManager:
635
624
  branch: Branch | str | None = None,
636
625
  include_metadata: MetadataQueryOptions | MetadataOptions = MetadataOptions.NONE,
637
626
  prefetch_relationships: bool = False,
638
- account=None,
639
627
  branch_agnostic: bool = False,
640
628
  ) -> Node | SchemaProtocol | None:
641
629
  branch = await registry.get_branch(branch=branch, db=db)
@@ -657,7 +645,6 @@ class NodeManager:
657
645
  at=at,
658
646
  include_metadata=include_metadata,
659
647
  prefetch_relationships=prefetch_relationships,
660
- account=account,
661
648
  branch_agnostic=branch_agnostic,
662
649
  order=OrderModel(disable=True),
663
650
  )
@@ -694,7 +681,6 @@ class NodeManager:
694
681
  branch: Branch | str | None = ...,
695
682
  include_metadata: MetadataQueryOptions | MetadataOptions = ...,
696
683
  prefetch_relationships: bool = ...,
697
- account=...,
698
684
  ) -> SchemaProtocol | None: ...
699
685
 
700
686
  @overload
@@ -710,7 +696,6 @@ class NodeManager:
710
696
  branch: Branch | str | None = ...,
711
697
  include_metadata: MetadataQueryOptions | MetadataOptions = ...,
712
698
  prefetch_relationships: bool = ...,
713
- account=...,
714
699
  branch_agnostic: bool = ...,
715
700
  ) -> SchemaProtocol: ...
716
701
 
@@ -727,7 +712,6 @@ class NodeManager:
727
712
  branch: Branch | str | None = ...,
728
713
  include_metadata: MetadataQueryOptions | MetadataOptions = ...,
729
714
  prefetch_relationships: bool = ...,
730
- account=...,
731
715
  branch_agnostic: bool = ...,
732
716
  ) -> SchemaProtocol | None: ...
733
717
 
@@ -744,7 +728,6 @@ class NodeManager:
744
728
  branch: Branch | str | None = ...,
745
729
  include_metadata: MetadataQueryOptions | MetadataOptions = ...,
746
730
  prefetch_relationships: bool = ...,
747
- account=...,
748
731
  branch_agnostic: bool = ...,
749
732
  ) -> Node: ...
750
733
 
@@ -761,7 +744,6 @@ class NodeManager:
761
744
  branch: Branch | str | None = ...,
762
745
  include_metadata: MetadataQueryOptions | MetadataOptions = ...,
763
746
  prefetch_relationships: bool = ...,
764
- account=...,
765
747
  branch_agnostic: bool = ...,
766
748
  ) -> Node | None: ...
767
749
 
@@ -778,7 +760,6 @@ class NodeManager:
778
760
  branch: Branch | str | None = ...,
779
761
  include_metadata: MetadataQueryOptions | MetadataOptions = ...,
780
762
  prefetch_relationships: bool = ...,
781
- account=...,
782
763
  branch_agnostic: bool = ...,
783
764
  ) -> Node | None: ...
784
765
 
@@ -794,7 +775,6 @@ class NodeManager:
794
775
  branch: Branch | str | None = None,
795
776
  include_metadata: MetadataQueryOptions | MetadataOptions = MetadataOptions.NONE,
796
777
  prefetch_relationships: bool = False,
797
- account=None,
798
778
  branch_agnostic: bool = False,
799
779
  ) -> Node | SchemaProtocol | None:
800
780
  branch = await registry.get_branch(branch=branch, db=db)
@@ -844,7 +824,6 @@ class NodeManager:
844
824
  at=at,
845
825
  include_metadata=include_metadata,
846
826
  prefetch_relationships=prefetch_relationships,
847
- account=account,
848
827
  branch_agnostic=branch_agnostic,
849
828
  order=OrderModel(disable=True),
850
829
  )
@@ -876,7 +855,6 @@ class NodeManager:
876
855
  branch: Branch | str | None = ...,
877
856
  include_metadata: MetadataQueryOptions | MetadataOptions = ...,
878
857
  prefetch_relationships: bool = ...,
879
- account=...,
880
858
  branch_agnostic: bool = ...,
881
859
  ) -> SchemaProtocol: ...
882
860
 
@@ -892,7 +870,6 @@ class NodeManager:
892
870
  branch: Branch | str | None = ...,
893
871
  include_metadata: MetadataQueryOptions | MetadataOptions = ...,
894
872
  prefetch_relationships: bool = ...,
895
- account=...,
896
873
  branch_agnostic: bool = ...,
897
874
  ) -> Any: ...
898
875
 
@@ -907,7 +884,6 @@ class NodeManager:
907
884
  branch: Branch | str | None = None,
908
885
  include_metadata: MetadataQueryOptions | MetadataOptions = MetadataOptions.NONE,
909
886
  prefetch_relationships: bool = False,
910
- account=None,
911
887
  branch_agnostic: bool = False,
912
888
  ) -> Any:
913
889
  branch = await registry.get_branch(branch=branch, db=db)
@@ -935,7 +911,6 @@ class NodeManager:
935
911
  branch=branch,
936
912
  include_metadata=include_metadata,
937
913
  prefetch_relationships=prefetch_relationships,
938
- account=account,
939
914
  branch_agnostic=branch_agnostic,
940
915
  )
941
916
  if not node:
infrahub/core/merge.py CHANGED
@@ -43,7 +43,7 @@ class BranchMerger:
43
43
  diff_locker: DiffLocker,
44
44
  destination_branch: Branch | None = None,
45
45
  workflow: InfrahubWorkflow | None = None,
46
- ):
46
+ ) -> None:
47
47
  self.source_branch = source_branch
48
48
  self.destination_branch: Branch = destination_branch or registry.get_branch_from_registry()
49
49
  self.db = db
@@ -52,6 +52,7 @@ from .m047_backfill_or_null_display_label import Migration047
52
52
  from .m048_undelete_rel_props import Migration048
53
53
  from .m049_remove_is_visible_relationship import Migration049
54
54
  from .m050_backfill_vertex_metadata import Migration050
55
+ from .m051_subtract_branched_from_microsecond import Migration051
55
56
 
56
57
  if TYPE_CHECKING:
57
58
  from ..shared import MigrationTypes
@@ -108,6 +109,7 @@ MIGRATIONS: list[type[MigrationTypes]] = [
108
109
  Migration048,
109
110
  Migration049,
110
111
  Migration050,
112
+ Migration051,
111
113
  ]
112
114
 
113
115
 
@@ -43,7 +43,7 @@ class Migration012RenameTypeAttributeData(AttributeRenameQuery):
43
43
  name = "migration_012_rename_attr_type"
44
44
  type = QueryType.WRITE
45
45
 
46
- def __init__(self, **kwargs: Any):
46
+ def __init__(self, **kwargs: Any) -> None:
47
47
  new_attr = AttributeInfo(
48
48
  name="account_type",
49
49
  node_kind=InfrahubKind.ACCOUNT,
@@ -83,7 +83,7 @@ class Migration012AddLabelData(NodeDuplicateQuery):
83
83
  name = "migration_012_add_labels"
84
84
  type = QueryType.WRITE
85
85
 
86
- def __init__(self, **kwargs: Any):
86
+ def __init__(self, **kwargs: Any) -> None:
87
87
  new_node = SchemaNodeInfo(
88
88
  name="Account",
89
89
  namespace="Core",
@@ -132,7 +132,7 @@ class Migration012RenameTypeAttributeSchema(SchemaAttributeUpdateQuery):
132
132
  type = QueryType.WRITE
133
133
  insert_return = False
134
134
 
135
- def __init__(self, **kwargs: Any):
135
+ def __init__(self, **kwargs: Any) -> None:
136
136
  super().__init__(
137
137
  attribute_name="name",
138
138
  node_name="Account",
@@ -150,7 +150,7 @@ class Migration012RenameRelationshipAccountTokenData(RelationshipDuplicateQuery)
150
150
  name = "migration_012_rename_rel_account_token_data"
151
151
  type = QueryType.WRITE
152
152
 
153
- def __init__(self, **kwargs: Any):
153
+ def __init__(self, **kwargs: Any) -> None:
154
154
  new_rel = SchemaRelationshipInfo(
155
155
  name="account__token",
156
156
  branch_support=BranchSupportType.AGNOSTIC.value,
@@ -173,7 +173,7 @@ class Migration012RenameRelationshipRefreshTokenData(RelationshipDuplicateQuery)
173
173
  name = "migration_012_rename_rel_refresh_token_data"
174
174
  type = QueryType.WRITE
175
175
 
176
- def __init__(self, **kwargs: Any):
176
+ def __init__(self, **kwargs: Any) -> None:
177
177
  new_rel = SchemaRelationshipInfo(
178
178
  name="account__refreshtoken",
179
179
  branch_support=BranchSupportType.AGNOSTIC.value,
@@ -196,7 +196,7 @@ class Migration012RenameRelationshipThreadData(RelationshipDuplicateQuery):
196
196
  name = "migration_012_rename_rel_thread_data"
197
197
  type = QueryType.WRITE
198
198
 
199
- def __init__(self, **kwargs: Any):
199
+ def __init__(self, **kwargs: Any) -> None:
200
200
  new_rel = SchemaRelationshipInfo(
201
201
  name="thread__account",
202
202
  branch_support=BranchSupportType.AGNOSTIC.value,
@@ -219,7 +219,7 @@ class Migration012RenameRelationshipCommentData(RelationshipDuplicateQuery):
219
219
  name = "migration_012_rename_rel_comment_data"
220
220
  type = QueryType.WRITE
221
221
 
222
- def __init__(self, **kwargs: Any):
222
+ def __init__(self, **kwargs: Any) -> None:
223
223
  new_rel = SchemaRelationshipInfo(
224
224
  name="comment__account",
225
225
  branch_support=BranchSupportType.AGNOSTIC.value,
@@ -243,7 +243,7 @@ class Migration012DeleteOldElementsSchema(DeleteElementInSchemaQuery):
243
243
  type = QueryType.WRITE
244
244
  insert_return = False
245
245
 
246
- def __init__(self, **kwargs: Any):
246
+ def __init__(self, **kwargs: Any) -> None:
247
247
  kwargs.pop("branch", None)
248
248
 
249
249
  super().__init__(
@@ -260,7 +260,7 @@ class Migration012UpdateDisplayLabels(SchemaAttributeUpdateQuery):
260
260
  type = QueryType.WRITE
261
261
  insert_return = False
262
262
 
263
- def __init__(self, **kwargs: Any):
263
+ def __init__(self, **kwargs: Any) -> None:
264
264
  kwargs.pop("branch", None)
265
265
 
266
266
  super().__init__(
@@ -277,7 +277,7 @@ class Migration012UpdateOrderBy(SchemaAttributeUpdateQuery):
277
277
  type = QueryType.WRITE
278
278
  insert_return = False
279
279
 
280
- def __init__(self, **kwargs: Any):
280
+ def __init__(self, **kwargs: Any) -> None:
281
281
  kwargs.pop("branch", None)
282
282
 
283
283
  super().__init__(
@@ -294,7 +294,7 @@ class Migration012UpdateDefaultFilter(SchemaAttributeUpdateQuery):
294
294
  type = QueryType.WRITE
295
295
  insert_return = False
296
296
 
297
- def __init__(self, **kwargs: Any):
297
+ def __init__(self, **kwargs: Any) -> None:
298
298
  kwargs.pop("branch", None)
299
299
 
300
300
  super().__init__(
@@ -311,7 +311,7 @@ class Migration012UpdateHFID(SchemaAttributeUpdateQuery):
311
311
  type = QueryType.WRITE
312
312
  insert_return = False
313
313
 
314
- def __init__(self, **kwargs: Any):
314
+ def __init__(self, **kwargs: Any) -> None:
315
315
  kwargs.pop("branch", None)
316
316
 
317
317
  super().__init__(
@@ -228,7 +228,7 @@ class Migration013DeleteUsernamePasswordGenericSchema(DeleteElementInSchemaQuery
228
228
  type = QueryType.WRITE
229
229
  insert_return = False
230
230
 
231
- def __init__(self, **kwargs: Any):
231
+ def __init__(self, **kwargs: Any) -> None:
232
232
  kwargs.pop("branch", None)
233
233
 
234
234
  super().__init__(
@@ -245,7 +245,7 @@ class Migration013DeleteUsernamePasswordReadWriteSchema(DeleteElementInSchemaQue
245
245
  type = QueryType.WRITE
246
246
  insert_return = False
247
247
 
248
- def __init__(self, **kwargs: Any):
248
+ def __init__(self, **kwargs: Any) -> None:
249
249
  kwargs.pop("branch", None)
250
250
 
251
251
  super().__init__(
@@ -262,7 +262,7 @@ class Migration013DeleteUsernamePasswordReadOnlySchema(DeleteElementInSchemaQuer
262
262
  type = QueryType.WRITE
263
263
  insert_return = False
264
264
 
265
- def __init__(self, **kwargs: Any):
265
+ def __init__(self, **kwargs: Any) -> None:
266
266
  kwargs.pop("branch", None)
267
267
 
268
268
  super().__init__(
@@ -277,7 +277,7 @@ class Migration013DeleteUsernamePasswordReadOnlySchema(DeleteElementInSchemaQuer
277
277
  class Migration013AddInternalStatusData(AttributeAddQuery):
278
278
  type = QueryType.WRITE
279
279
 
280
- def __init__(self, **kwargs: Any):
280
+ def __init__(self, **kwargs: Any) -> None:
281
281
  kwargs.pop("branch", None)
282
282
 
283
283
  super().__init__(
@@ -3,7 +3,7 @@ from __future__ import annotations
3
3
  from typing import TYPE_CHECKING, Sequence
4
4
 
5
5
  from infrahub.constants.database import IndexType
6
- from infrahub.core.migrations.shared import MigrationResult
6
+ from infrahub.core.migrations.shared import MigrationInput, MigrationResult
7
7
  from infrahub.core.query import Query # noqa: TC001
8
8
  from infrahub.database import DatabaseType
9
9
  from infrahub.database.index import IndexItem
@@ -23,7 +23,8 @@ class Migration014(GraphMigration):
23
23
  queries: Sequence[type[Query]] = []
24
24
  minimum_version: int = 13
25
25
 
26
- async def execute(self, db: InfrahubDatabase) -> MigrationResult:
26
+ async def execute(self, migration_input: MigrationInput) -> MigrationResult:
27
+ db = migration_input.db
27
28
  result = MigrationResult()
28
29
 
29
30
  # Only execute this migration for Neo4j
@@ -4,7 +4,7 @@ from typing import TYPE_CHECKING
4
4
 
5
5
  from infrahub.core import registry
6
6
  from infrahub.core.diff.repository.repository import DiffRepository
7
- from infrahub.core.migrations.shared import MigrationResult
7
+ from infrahub.core.migrations.shared import MigrationInput, MigrationResult
8
8
  from infrahub.dependencies.registry import build_component_registry, get_component_registry
9
9
  from infrahub.log import get_logger
10
10
 
@@ -25,7 +25,8 @@ class Migration015(ArbitraryMigration):
25
25
 
26
26
  return result
27
27
 
28
- async def execute(self, db: InfrahubDatabase) -> MigrationResult:
28
+ async def execute(self, migration_input: MigrationInput) -> MigrationResult:
29
+ db = migration_input.db
29
30
  default_branch = registry.get_branch_from_registry()
30
31
  build_component_registry()
31
32
  component_registry = get_component_registry()
@@ -4,7 +4,7 @@ from typing import TYPE_CHECKING
4
4
 
5
5
  from infrahub.core import registry
6
6
  from infrahub.core.diff.repository.repository import DiffRepository
7
- from infrahub.core.migrations.shared import MigrationResult
7
+ from infrahub.core.migrations.shared import MigrationInput, MigrationResult
8
8
  from infrahub.dependencies.registry import build_component_registry, get_component_registry
9
9
  from infrahub.log import get_logger
10
10
 
@@ -25,7 +25,8 @@ class Migration016(ArbitraryMigration):
25
25
 
26
26
  return result
27
27
 
28
- async def execute(self, db: InfrahubDatabase) -> MigrationResult:
28
+ async def execute(self, migration_input: MigrationInput) -> MigrationResult:
29
+ db = migration_input.db
29
30
  default_branch = registry.get_branch_from_registry()
30
31
  build_component_registry()
31
32
  component_registry = get_component_registry()
@@ -3,8 +3,7 @@ from __future__ import annotations
3
3
  from typing import TYPE_CHECKING, Sequence
4
4
 
5
5
  from infrahub.core import registry
6
- from infrahub.core.constants import SYSTEM_USER_ID
7
- from infrahub.core.migrations.shared import MigrationResult
6
+ from infrahub.core.migrations.shared import MigrationInput, MigrationResult
8
7
  from infrahub.core.schema.definitions.core import core_profile_schema_definition
9
8
  from infrahub.core.schema.manager import SchemaManager
10
9
  from infrahub.log import get_logger
@@ -27,17 +26,20 @@ class Migration017(InternalSchemaMigration):
27
26
 
28
27
  return result
29
28
 
30
- async def execute(self, db: InfrahubDatabase, user_id: str = SYSTEM_USER_ID) -> MigrationResult:
29
+ async def execute(self, migration_input: MigrationInput) -> MigrationResult:
31
30
  """
32
31
  Load CoreProfile schema node in db.
33
32
  """
33
+ db = migration_input.db
34
+ at = migration_input.at
35
+ user_id = migration_input.user_id
34
36
  default_branch = registry.get_branch_from_registry()
35
37
  manager = SchemaManager()
36
38
  manager.set_schema_branch(name=default_branch.name, schema=self.get_internal_schema())
37
39
 
38
40
  db.add_schema(manager.get_schema_branch(default_branch.name))
39
41
  await manager.load_node_to_db(
40
- node=core_profile_schema_definition, db=db, branch=default_branch, user_id=user_id
42
+ node=core_profile_schema_definition, db=db, branch=default_branch, user_id=user_id, at=at
41
43
  )
42
44
 
43
45
  return MigrationResult()
@@ -4,9 +4,8 @@ from collections import defaultdict
4
4
  from typing import TYPE_CHECKING, Sequence
5
5
 
6
6
  from infrahub.core import registry
7
- from infrahub.core.constants import SYSTEM_USER_ID
8
7
  from infrahub.core.diff.payload_builder import get_display_labels_per_kind
9
- from infrahub.core.migrations.shared import MigrationResult
8
+ from infrahub.core.migrations.shared import MigrationInput, MigrationResult
10
9
  from infrahub.core.schema import GenericSchema, NodeSchema, SchemaRoot, internal_schema
11
10
  from infrahub.core.schema.manager import SchemaManager
12
11
  from infrahub.core.validators.uniqueness.checker import UniquenessChecker
@@ -96,5 +95,5 @@ class Migration018(InternalSchemaMigration):
96
95
  async def validate_migration(self, db: InfrahubDatabase) -> MigrationResult: # noqa: ARG002
97
96
  return MigrationResult()
98
97
 
99
- async def execute(self, db: InfrahubDatabase, user_id: str = SYSTEM_USER_ID) -> MigrationResult: # noqa: ARG002
100
- return await validate_nulls_in_uniqueness_constraints(db=db)
98
+ async def execute(self, migration_input: MigrationInput) -> MigrationResult:
99
+ return await validate_nulls_in_uniqueness_constraints(db=migration_input.db)
@@ -3,7 +3,7 @@ from __future__ import annotations
3
3
  from typing import TYPE_CHECKING, Any, Sequence
4
4
 
5
5
  from infrahub.core.constants.database import DatabaseEdgeType
6
- from infrahub.core.migrations.shared import GraphMigration, MigrationResult
6
+ from infrahub.core.migrations.shared import GraphMigration, MigrationInput, MigrationResult
7
7
  from infrahub.log import get_logger
8
8
 
9
9
  from ...query import Query, QueryType
@@ -140,9 +140,9 @@ class Migration020(GraphMigration):
140
140
  DeleteDuplicateIsProtectedEdgesQuery,
141
141
  ]
142
142
 
143
- async def execute(self, db: InfrahubDatabase) -> MigrationResult:
143
+ async def execute(self, migration_input: MigrationInput) -> MigrationResult:
144
144
  # skip the transaction b/c it will run out of memory on a large database
145
- return await self.do_execute(db=db)
145
+ return await self.do_execute(migration_input=migration_input)
146
146
 
147
147
  async def validate_migration(self, db: InfrahubDatabase) -> MigrationResult: # noqa: ARG002
148
148
  result = MigrationResult()
@@ -2,8 +2,7 @@ from __future__ import annotations
2
2
 
3
3
  from typing import TYPE_CHECKING, Sequence
4
4
 
5
- from infrahub.core.constants import SYSTEM_USER_ID
6
- from infrahub.core.migrations.shared import MigrationResult
5
+ from infrahub.core.migrations.shared import MigrationInput, MigrationResult
7
6
  from infrahub.log import get_logger
8
7
 
9
8
  from ..shared import InternalSchemaMigration, SchemaMigration
@@ -23,5 +22,5 @@ class Migration025(InternalSchemaMigration):
23
22
  async def validate_migration(self, db: InfrahubDatabase) -> MigrationResult: # noqa: ARG002
24
23
  return MigrationResult()
25
24
 
26
- async def execute(self, db: InfrahubDatabase, user_id: str = SYSTEM_USER_ID) -> MigrationResult: # noqa: ARG002
27
- return await validate_nulls_in_uniqueness_constraints(db=db)
25
+ async def execute(self, migration_input: MigrationInput) -> MigrationResult:
26
+ return await validate_nulls_in_uniqueness_constraints(db=migration_input.db)
@@ -4,12 +4,10 @@ import ipaddress
4
4
  from typing import TYPE_CHECKING, Sequence
5
5
 
6
6
  from infrahub.core.branch.models import Branch
7
- from infrahub.core.constants import SYSTEM_USER_ID
8
7
  from infrahub.core.initialization import initialization
9
8
  from infrahub.core.ipam.reconciler import IpamReconciler
10
9
  from infrahub.core.manager import NodeManager
11
- from infrahub.core.migrations.shared import MigrationResult
12
- from infrahub.core.timestamp import Timestamp
10
+ from infrahub.core.migrations.shared import MigrationInput, MigrationResult
13
11
  from infrahub.lock import initialize_lock
14
12
  from infrahub.log import get_logger
15
13
 
@@ -29,12 +27,13 @@ class Migration026(InternalSchemaMigration):
29
27
  async def validate_migration(self, db: InfrahubDatabase) -> MigrationResult: # noqa: ARG002
30
28
  return MigrationResult()
31
29
 
32
- async def execute(self, db: InfrahubDatabase, user_id: str = SYSTEM_USER_ID) -> MigrationResult: # noqa: ARG002
30
+ async def execute(self, migration_input: MigrationInput) -> MigrationResult:
31
+ db = migration_input.db
32
+ at = migration_input.at
33
33
  # load schemas from database into registry
34
34
  initialize_lock()
35
35
  await initialization(db=db)
36
36
 
37
- at = Timestamp()
38
37
  for branch in await Branch.get_list(db=db):
39
38
  prefix_0000s = await NodeManager.query(
40
39
  db=db, schema="BuiltinIPPrefix", branch=branch, filters={"prefix__values": ["0.0.0.0/0", "::/0"]}
@@ -4,7 +4,7 @@ from typing import TYPE_CHECKING
4
4
 
5
5
  from infrahub.core import registry
6
6
  from infrahub.core.diff.repository.repository import DiffRepository
7
- from infrahub.core.migrations.shared import MigrationResult
7
+ from infrahub.core.migrations.shared import MigrationInput, MigrationResult
8
8
  from infrahub.dependencies.registry import build_component_registry, get_component_registry
9
9
  from infrahub.log import get_logger
10
10
 
@@ -27,7 +27,8 @@ class Migration028(ArbitraryMigration):
27
27
 
28
28
  return result
29
29
 
30
- async def execute(self, db: InfrahubDatabase) -> MigrationResult:
30
+ async def execute(self, migration_input: MigrationInput) -> MigrationResult:
31
+ db = migration_input.db
31
32
  default_branch = registry.get_branch_from_registry()
32
33
  build_component_registry()
33
34
  component_registry = get_component_registry()
@@ -4,7 +4,7 @@ from typing import TYPE_CHECKING, Any, Literal
4
4
 
5
5
  from infrahub.core.constants import RelationshipDirection
6
6
  from infrahub.core.constants.database import DatabaseEdgeType
7
- from infrahub.core.migrations.shared import MigrationResult
7
+ from infrahub.core.migrations.shared import MigrationInput, MigrationResult
8
8
  from infrahub.core.query import Query, QueryType
9
9
  from infrahub.log import get_logger
10
10
 
@@ -574,8 +574,9 @@ class Migration029(ArbitraryMigration):
574
574
 
575
575
  return result
576
576
 
577
- async def execute(self, db: InfrahubDatabase) -> MigrationResult:
577
+ async def execute(self, migration_input: MigrationInput) -> MigrationResult:
578
578
  migration_result = MigrationResult()
579
+ db = migration_input.db
579
580
  limit = self.limit
580
581
  offset = 0
581
582
  more_nodes_to_process = True
@@ -5,9 +5,9 @@ from typing import TYPE_CHECKING, Sequence
5
5
  from infrahub import config
6
6
  from infrahub.core import registry
7
7
  from infrahub.core.branch import Branch
8
- from infrahub.core.constants import SYSTEM_USER_ID, SchemaPathType
8
+ from infrahub.core.constants import SchemaPathType
9
9
  from infrahub.core.initialization import initialization
10
- from infrahub.core.migrations.shared import InternalSchemaMigration, MigrationResult, SchemaMigration
10
+ from infrahub.core.migrations.shared import InternalSchemaMigration, MigrationInput, MigrationResult, SchemaMigration
11
11
  from infrahub.core.path import SchemaPath
12
12
  from infrahub.core.schema import GenericSchema, NodeSchema
13
13
  from infrahub.core.schema.attribute_parameters import NumberAttributeParameters
@@ -35,7 +35,7 @@ class Migration031(InternalSchemaMigration):
35
35
  minimum_version: int = 30
36
36
  migrations: Sequence[SchemaMigration] = []
37
37
 
38
- async def execute(self, db: InfrahubDatabase, user_id: str = SYSTEM_USER_ID) -> MigrationResult: # noqa: ARG002
38
+ async def execute(self, migration_input: MigrationInput) -> MigrationResult:
39
39
  """Retrieve all number attributes that have a min/max/excluded_values
40
40
  For any of these attributes, check if corresponding existing nodes are valid."""
41
41
 
@@ -43,6 +43,7 @@ class Migration031(InternalSchemaMigration):
43
43
  return MigrationResult()
44
44
 
45
45
  # load schemas from database into registry
46
+ db = migration_input.db
46
47
  initialize_lock()
47
48
  await initialization(db=db)
48
49