'Doctrine Migration update one table based on value from another table

I'm not sure what I'm doing wrong. So I have 2 tables users and user_phone. Each user has a phone_number1 and phone_number2. The phone number are currently in the user_phone table. Now i added the phone_number1 and phone_number2 columns in the users table. So I want to move all the phone numbers from user_phone to users table for each user. But my logic below since not working. throwing.

DoctrineMigrations\Version20220222224248 failed during Execution. Error: "An exception occurred while executing 'UPDATE usersSETphone_number1= '666-666-6666,phone_number2= 999-999-9999 WHEREid = 12':

And here the code I'm currently running.

public function up(Schema $schema): void
{
    // this up() migration is auto-generated, please modify it to your needs
    if($schema->getTable('users')->hasColumn('phone_number1')) {

        $phone_numbers   = $this->connection->fetchAll("SELECT * FROM user_phone");
        $users           = $this->connection->iterateColumn("SELECT id FROM users");

        
        foreach($phone_numbers as $number) {
            $phone1 = $number['phone_number1'];
            $phone2 = $number['phone_number2'];
            $phone_id = $number['id'];
            foreach($users as $user) {
                $this->connection->executeUpdate("UPDATE `users` SET `phone_number1` = $phone1, `phone_number2` = $phone2 WHERE `id` = '$phone_id');
            }
        }
    }

}


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source