@@ -13,11 +13,14 @@ use diesel::{
13
13
sql_query,
14
14
sql_types:: { Nullable , Text } ,
15
15
} ;
16
- use graph:: prelude:: {
17
- anyhow, bigdecimal:: ToPrimitive , hex, web3:: types:: H256 , BigDecimal , BlockNumber , BlockPtr ,
18
- DeploymentHash , DeploymentState , Schema , StoreError ,
19
- } ;
20
16
use graph:: { blockchain:: block_stream:: FirehoseCursor , data:: subgraph:: schema:: SubgraphError } ;
17
+ use graph:: {
18
+ components:: store:: EntityType ,
19
+ prelude:: {
20
+ anyhow, bigdecimal:: ToPrimitive , hex, web3:: types:: H256 , BigDecimal , BlockNumber , BlockPtr ,
21
+ DeploymentHash , DeploymentState , Schema , StoreError ,
22
+ } ,
23
+ } ;
21
24
use graph:: {
22
25
data:: subgraph:: {
23
26
schema:: { DeploymentCreate , SubgraphManifestEntity } ,
@@ -84,6 +87,10 @@ table! {
84
87
current_reorg_depth -> Integer ,
85
88
max_reorg_depth -> Integer ,
86
89
firehose_cursor -> Nullable <Text >,
90
+
91
+ // Entity types that have a `causality_region` column.
92
+ // Names stored as present in the schema, not in snake case.
93
+ has_causality_region -> Array <Text >,
87
94
}
88
95
}
89
96
@@ -769,6 +776,19 @@ pub(crate) fn health(conn: &PgConnection, id: DeploymentId) -> Result<SubgraphHe
769
776
. map_err ( |e| e. into ( ) )
770
777
}
771
778
779
+ pub ( crate ) fn has_causality_region (
780
+ conn : & PgConnection ,
781
+ id : DeploymentId ,
782
+ ) -> Result < Vec < EntityType > , StoreError > {
783
+ use subgraph_deployment as d;
784
+
785
+ d:: table
786
+ . filter ( d:: id. eq ( id) )
787
+ . select ( d:: has_causality_region)
788
+ . get_result ( conn)
789
+ . map_err ( |e| e. into ( ) )
790
+ }
791
+
772
792
/// Reverts the errors and updates the subgraph health if necessary.
773
793
pub ( crate ) fn revert_subgraph_errors (
774
794
conn : & PgConnection ,
@@ -916,8 +936,10 @@ pub fn create_deployment(
916
936
graft_base,
917
937
graft_block,
918
938
debug_fork,
939
+ has_causality_region,
919
940
} = deployment;
920
941
let earliest_block_number = start_block. as_ref ( ) . map ( |ptr| ptr. number ) . unwrap_or ( 0 ) ;
942
+ let has_causality_region = Vec :: from_iter ( has_causality_region. into_iter ( ) ) ;
921
943
922
944
let deployment_values = (
923
945
d:: id. eq ( site. id ) ,
@@ -935,6 +957,7 @@ pub fn create_deployment(
935
957
d:: graft_block_hash. eq ( b ( & graft_block) ) ,
936
958
d:: graft_block_number. eq ( n ( & graft_block) ) ,
937
959
d:: debug_fork. eq ( debug_fork. as_ref ( ) . map ( |s| s. as_str ( ) ) ) ,
960
+ d:: has_causality_region. eq ( has_causality_region) ,
938
961
) ;
939
962
940
963
let graph_node_version_id = GraphNodeVersion :: create_or_get ( conn) ?;
0 commit comments