@@ -294,23 +294,30 @@ def flexible_server_version_upgrade(cmd, client, resource_group_name, server_nam
294294 if instance .sku .tier == 'Burstable' :
295295 raise CLIError ("Major version update is not supported for the Burstable pricing tier." )
296296
297- current_version = int (instance .version .split ('.' )[0 ])
298- if current_version >= int (version ):
299- raise CLIError ("The version to upgrade to must be greater than the current version." )
300-
301297 replica_operations_client = cf_mysql_flexible_replica (cmd .cli_ctx , '_' )
302298 mysql_version_map = {
303299 '8' : '8.0.21' ,
300+ '8.4' : '8.4'
304301 }
305302 version_mapped = mysql_version_map [version ]
306303
304+ current_major_version = int (instance .version .split ('.' )[0 ])
305+ current_minor_version = int (instance .version .split ('.' )[1 ])
306+
307+ target_major_version = int (version_mapped .split ('.' )[0 ])
308+ target_minor_version = int (version_mapped .split ('.' )[1 ])
309+
310+ if current_major_version > target_major_version or (current_major_version == target_major_version and current_minor_version >= target_minor_version ):
311+ raise CLIError ("The version to upgrade to must be greater than the current version." )
312+
307313 replicas = replica_operations_client .list_by_server (resource_group_name , server_name )
308314
309315 for replica in replicas :
310- current_replica_version = int (replica .version .split ('.' )[0 ])
311- if current_replica_version < int (version ):
316+ current_replica_major_version = int (replica .version .split ('.' )[0 ])
317+ current_replica_minor_version = int (replica .version .split ('.' )[1 ])
318+ if current_replica_major_version < target_major_version or (current_replica_major_version == target_major_version and current_replica_minor_version < target_minor_version ):
312319 raise CLIError ("Primary server version must not be greater than replica server version. "
313- "First upgrade {} server version to {} and try again." .format (replica .name , version ))
320+ "First upgrade {} server version to {} and try again." .format (replica .name , version_mapped ))
314321
315322 parameters = {
316323 'version' : version_mapped
0 commit comments