@@ -58,7 +58,7 @@ pub struct TrackingTableSetupStatusCheck {
5858
5959 pub legacy_table_names : Vec < String > ,
6060
61- pub min_existing_version_ids : Option < i32 > ,
61+ pub min_existing_version_id : Option < i32 > ,
6262 pub source_ids_to_delete : Vec < i32 > ,
6363}
6464
@@ -75,7 +75,10 @@ impl TrackingTableSetupStatusCheck {
7575 . into_iter ( )
7676 . cloned ( )
7777 . collect ( ) ,
78- min_existing_version_ids : existing. possible_versions ( ) . map ( |v| v. version_id ) . min ( ) ,
78+ min_existing_version_id : existing
79+ . always_exists ( )
80+ . then ( || existing. possible_versions ( ) . map ( |v| v. version_id ) . min ( ) )
81+ . flatten ( ) ,
7982 source_ids_to_delete,
8083 }
8184 }
@@ -102,7 +105,7 @@ impl ResourceSetupStatusCheck for TrackingTableSetupStatusCheck {
102105 self . legacy_table_names. join( ", " )
103106 ) ) ;
104107 }
105- match ( self . min_existing_version_ids , & self . desired_state ) {
108+ match ( self . min_existing_version_id , & self . desired_state ) {
106109 ( None , Some ( state) ) => {
107110 changes. push ( format ! ( "Create the tracking table: {}. " , state. table_name) )
108111 }
@@ -131,7 +134,7 @@ impl ResourceSetupStatusCheck for TrackingTableSetupStatusCheck {
131134 }
132135
133136 fn change_type ( & self ) -> SetupChangeType {
134- match ( self . min_existing_version_ids , & self . desired_state ) {
137+ match ( self . min_existing_version_id , & self . desired_state ) {
135138 ( None , Some ( _) ) => SetupChangeType :: Create ,
136139 ( Some ( min_version_id) , Some ( desired) ) => {
137140 if min_version_id == desired. version_id && self . legacy_table_names . is_empty ( ) {
@@ -158,11 +161,11 @@ impl ResourceSetupStatusCheck for TrackingTableSetupStatusCheck {
158161 sqlx:: query ( & query) . execute ( pool) . await ?;
159162 }
160163
161- if self . min_existing_version_ids != Some ( desired. version_id ) {
164+ if self . min_existing_version_id != Some ( desired. version_id ) {
162165 upgrade_tracking_table (
163166 pool,
164167 & desired. table_name ,
165- self . min_existing_version_ids . unwrap_or ( 0 ) ,
168+ self . min_existing_version_id . unwrap_or ( 0 ) ,
166169 desired. version_id ,
167170 )
168171 . await ?;
0 commit comments