File tree Expand file tree Collapse file tree 1 file changed +10
-8
lines changed
toolkit/data-sources/db-sync/src Expand file tree Collapse file tree 1 file changed +10
-8
lines changed Original file line number Diff line number Diff line change @@ -23,15 +23,17 @@ pub(crate) enum TxInConfiguration {
23
23
24
24
impl TxInConfiguration {
25
25
pub ( crate ) async fn from_connection ( pool : & Pool < Postgres > ) -> Result < Self , SqlxError > {
26
- let query = sqlx:: query_scalar :: < _ , i64 > (
27
- "select count(*) from information_schema.tables where table_name = 'tx_in' ;" ,
28
- ) ;
29
-
30
- if query . fetch_all ( pool ) . await ?. first ( ) == Some ( & 0 ) {
31
- Ok ( Self :: Consumed )
32
- } else {
33
- Ok ( Self :: Legacy )
26
+ let consumed_by_tx_id_populated = sqlx:: query_scalar :: < _ , bool > (
27
+ "SELECT EXISTS (SELECT 1 FROM tx_out where consumed_by_tx_id is not null) ;" ,
28
+ )
29
+ . fetch_one ( pool )
30
+ . await ?;
31
+
32
+ if consumed_by_tx_id_populated {
33
+ return Ok ( Self :: Consumed ) ;
34
34
}
35
+
36
+ Ok ( Self :: Legacy )
35
37
}
36
38
}
37
39
You can’t perform that action at this time.
0 commit comments