<?php

namespace HelpGent\Database\Migrations\V224;

defined( 'ABSPATH' ) || exit;

use HelpGent\Database\Migrations\Query;

class MiscellaneousMigration {
    public static function contact_info_migration(): bool {
        Query::safe_query(
            function () {
                global $wpdb;

                $sql = "UPDATE {$wpdb->prefix}helpgent_contact_info AS contact_info
                    JOIN {$wpdb->prefix}helpgent_element_answers AS element_answer
                    ON contact_info.answer_id = element_answer.id
                    SET 
                        contact_info.response_id = element_answer.response_id,
                        contact_info.name = CONCAT_WS(' ', contact_info.first_name, contact_info.last_name)
                ";

                Query::execute( $sql );
            },
        );

        return false;
    }
}