@@ -325,7 +325,10 @@ impl<T: WriteConnectionProvider + ?Sized + Sync> DatabaseWriteOperations for T {
325325 models:: batch_commit:: Entity :: update_many ( )
326326 . filter ( models:: batch_commit:: Column :: Hash . is_in ( batch_hashes. iter ( ) . cloned ( ) ) )
327327 . col_expr ( models:: batch_commit:: Column :: RevertedBlockNumber , Expr :: value ( None :: < i64 > ) )
328- . col_expr ( models:: batch_commit:: Column :: Status , Expr :: value ( "consolidated" ) )
328+ . col_expr (
329+ models:: batch_commit:: Column :: Status ,
330+ Expr :: value ( BatchStatus :: Consolidated . as_str ( ) ) ,
331+ )
329332 . exec ( self . get_connection ( ) )
330333 . await ?;
331334
@@ -342,8 +345,11 @@ impl<T: WriteConnectionProvider + ?Sized + Sync> DatabaseWriteOperations for T {
342345 tracing:: trace!( target: "scroll::db" , "Changing batch status from processing to committed in database." ) ;
343346
344347 models:: batch_commit:: Entity :: update_many ( )
345- . filter ( models:: batch_commit:: Column :: Status . eq ( "processing" ) )
346- . col_expr ( models:: batch_commit:: Column :: Status , Expr :: value ( "committed" ) )
348+ . filter ( models:: batch_commit:: Column :: Status . eq ( BatchStatus :: Processing . as_str ( ) ) )
349+ . col_expr (
350+ models:: batch_commit:: Column :: Status ,
351+ Expr :: value ( BatchStatus :: Committed . as_str ( ) ) ,
352+ )
347353 . exec ( self . get_connection ( ) )
348354 . await ?;
349355
@@ -359,7 +365,7 @@ impl<T: WriteConnectionProvider + ?Sized + Sync> DatabaseWriteOperations for T {
359365
360366 models:: batch_commit:: Entity :: update_many ( )
361367 . filter ( models:: batch_commit:: Column :: Hash . eq ( batch_hash. to_vec ( ) ) )
362- . col_expr ( models:: batch_commit:: Column :: Status , Expr :: value ( status. to_string ( ) ) )
368+ . col_expr ( models:: batch_commit:: Column :: Status , Expr :: value ( status. as_str ( ) ) )
363369 . exec ( self . get_connection ( ) )
364370 . await ?;
365371
@@ -465,7 +471,7 @@ impl<T: WriteConnectionProvider + ?Sized + Sync> DatabaseWriteOperations for T {
465471 let filter = Condition :: all ( )
466472 . add ( models:: batch_commit:: Column :: FinalizedBlockNumber . is_not_null ( ) )
467473 . add ( models:: batch_commit:: Column :: FinalizedBlockNumber . lte ( finalized_l1_block_number) )
468- . add ( models:: batch_commit:: Column :: Status . eq ( "consolidated" ) ) ;
474+ . add ( models:: batch_commit:: Column :: Status . eq ( BatchStatus :: Consolidated . as_str ( ) ) ) ;
469475 let batch = models:: batch_commit:: Entity :: find ( )
470476 . filter ( filter. clone ( ) )
471477 . order_by_desc ( models:: batch_commit:: Column :: Index )
@@ -482,7 +488,10 @@ impl<T: WriteConnectionProvider + ?Sized + Sync> DatabaseWriteOperations for T {
482488 . expect ( "Finalized batch must have at least one L2 block." ) ;
483489 models:: batch_commit:: Entity :: update_many ( )
484490 . filter ( filter)
485- . col_expr ( models:: batch_commit:: Column :: Status , Expr :: value ( "finalized" ) )
491+ . col_expr (
492+ models:: batch_commit:: Column :: Status ,
493+ Expr :: value ( BatchStatus :: Finalized . as_str ( ) ) ,
494+ )
486495 . exec ( self . get_connection ( ) )
487496 . await ?;
488497
@@ -499,7 +508,7 @@ impl<T: WriteConnectionProvider + ?Sized + Sync> DatabaseWriteOperations for T {
499508 let conditions = Condition :: all ( )
500509 . add ( models:: batch_commit:: Column :: FinalizedBlockNumber . is_not_null ( ) )
501510 . add ( models:: batch_commit:: Column :: FinalizedBlockNumber . lte ( finalized_l1_block_number) )
502- . add ( models:: batch_commit:: Column :: Status . eq ( "committed" ) ) ;
511+ . add ( models:: batch_commit:: Column :: Status . eq ( BatchStatus :: Committed . as_str ( ) ) ) ;
503512
504513 let batches = models:: batch_commit:: Entity :: find ( )
505514 . filter ( conditions. clone ( ) )
@@ -517,7 +526,10 @@ impl<T: WriteConnectionProvider + ?Sized + Sync> DatabaseWriteOperations for T {
517526 } ) ?;
518527
519528 models:: batch_commit:: Entity :: update_many ( )
520- . col_expr ( models:: batch_commit:: Column :: Status , Expr :: value ( "processing" ) )
529+ . col_expr (
530+ models:: batch_commit:: Column :: Status ,
531+ Expr :: value ( BatchStatus :: Processing . as_str ( ) ) ,
532+ )
521533 . filter ( conditions)
522534 . exec ( self . get_connection ( ) )
523535 . await ?;
@@ -528,7 +540,8 @@ impl<T: WriteConnectionProvider + ?Sized + Sync> DatabaseWriteOperations for T {
528540 async fn fetch_and_update_unprocessed_committed_batches (
529541 & self ,
530542 ) -> Result < Vec < BatchInfo > , DatabaseError > {
531- let conditions = Condition :: all ( ) . add ( models:: batch_commit:: Column :: Status . eq ( "committed" ) ) ;
543+ let conditions = Condition :: all ( )
544+ . add ( models:: batch_commit:: Column :: Status . eq ( BatchStatus :: Committed . as_str ( ) ) ) ;
532545
533546 let batches = models:: batch_commit:: Entity :: find ( )
534547 . filter ( conditions. clone ( ) )
@@ -546,7 +559,10 @@ impl<T: WriteConnectionProvider + ?Sized + Sync> DatabaseWriteOperations for T {
546559 } ) ?;
547560
548561 models:: batch_commit:: Entity :: update_many ( )
549- . col_expr ( models:: batch_commit:: Column :: Status , Expr :: value ( "processing" ) )
562+ . col_expr (
563+ models:: batch_commit:: Column :: Status ,
564+ Expr :: value ( BatchStatus :: Processing . as_str ( ) ) ,
565+ )
550566 . filter ( conditions)
551567 . exec ( self . get_connection ( ) )
552568 . await ?;
0 commit comments