File tree Expand file tree Collapse file tree 1 file changed +16
-6
lines changed
toolkit/data-sources/db-sync/src Expand file tree Collapse file tree 1 file changed +16
-6
lines changed Original file line number Diff line number Diff line change @@ -23,15 +23,25 @@ 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 > (
26
+ let tx_in_exists = sqlx:: query_scalar :: < _ , i64 > (
27
27
"select count(*) from information_schema.tables where table_name = 'tx_in';" ,
28
- ) ;
28
+ )
29
+ . fetch_one ( pool)
30
+ . await ? == 1 ;
29
31
30
- if query. fetch_all ( pool) . await ?. first ( ) == Some ( & 0 ) {
31
- Ok ( Self :: Consumed )
32
- } else {
33
- Ok ( Self :: Legacy )
32
+ if !tx_in_exists {
33
+ return Ok ( Self :: Consumed ) ;
34
34
}
35
+
36
+ let tx_in_populated = sqlx:: query_scalar :: < _ , bool > ( "SELECT EXISTS (SELECT 1 FROM tx_in);" )
37
+ . fetch_one ( pool)
38
+ . await ?;
39
+
40
+ if tx_in_populated {
41
+ return Ok ( Self :: Legacy ) ;
42
+ }
43
+
44
+ Ok ( Self :: Consumed )
35
45
}
36
46
}
37
47
You can’t perform that action at this time.
0 commit comments