<?php
declare(strict_types=1);
namespace DoctrineMigrations;
use Doctrine\DBAL\Schema\Schema;
use Doctrine\Migrations\AbstractMigration;
final class Version20260407173147 extends AbstractMigration
{
public function getDescription(): string
{
return 'Convert phone numbers from format (0xxxxx/+xxxxx) to international format (0033xxxx/00xxxx)';
}
public function up(Schema $schema): void
{
$this->addSql("UPDATE user SET phone = CONCAT('0033', SUBSTRING(phone, 2)) WHERE phone LIKE '0%' AND phone NOT LIKE '0033%'");
$this->addSql("UPDATE user SET phone = CONCAT('00', SUBSTRING(phone, 2)) WHERE phone LIKE '+%'");
}
public function down(Schema $schema): void
{
$this->addSql("UPDATE user SET phone = CONCAT('+', SUBSTRING(phone, 3)) WHERE phone LIKE '0%' AND phone NOT LIKE '0033%'");
$this->addSql("UPDATE user SET phone = CONCAT('0', SUBSTRING(phone, 5)) WHERE phone LIKE '0033%'");
}
}