$state['db_runner_active']     = false;
$state['db_runner_completed_at'] = time();
$state['cleanup_pending']      = true;
$state['cleanup_completed']    = false;
$state['cleanup_scheduled_at'] = time();
$state['status']               = 'completed';
$state['finalized']            = true;
$state['current_step']         = 'cleanup';
$state['progress']             = 100;
$state['message'] = 'Migration completed successfully! Redirecting to login';
$state['redirect_countdown']   = 60;
$state['redirect_url']         = rtrim( $new_url, '/' ) . '/wp-login.php';

// Stable completion summary for DB step.
$state['collation_remap_count']  = (int) $collation_remap_count;
$state['collation_remap_target'] = (string) $collation_remap_target;
$state['sub_progress'] = array(
	'label'           => 'done',
	'tables_imported' => $total_tables > 0 ? $total_tables : $tables_completed,
	'rows_imported'   => $total_rows > 0 ? $total_rows : $rows_imported,
);
if ( $collation_remap_count > 0 ) {
	$state['sub_progress']['collation_remap_count']  = (int) $collation_remap_count;
	$state['sub_progress']['collation_remap_target'] = (string) $collation_remap_target;
}
