33 lines
1021 B
PHP
33 lines
1021 B
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace DoctrineMigrations;
|
|
|
|
use Doctrine\DBAL\Schema\Schema;
|
|
use Doctrine\Migrations\AbstractMigration;
|
|
|
|
final class Version20260213093000 extends AbstractMigration
|
|
{
|
|
public function getDescription(): string
|
|
{
|
|
return 'Add name, phone and email fields to customer.';
|
|
}
|
|
|
|
public function up(Schema $schema): void
|
|
{
|
|
$this->addSql('ALTER TABLE customer ADD name VARCHAR(255) DEFAULT NULL');
|
|
$this->addSql('ALTER TABLE customer ADD phone VARCHAR(255) DEFAULT NULL');
|
|
$this->addSql('ALTER TABLE customer ADD email VARCHAR(255) DEFAULT NULL');
|
|
$this->addSql('UPDATE customer SET name = label WHERE name IS NULL');
|
|
$this->addSql('ALTER TABLE customer ALTER COLUMN name SET NOT NULL');
|
|
}
|
|
|
|
public function down(Schema $schema): void
|
|
{
|
|
$this->addSql('ALTER TABLE customer DROP name');
|
|
$this->addSql('ALTER TABLE customer DROP phone');
|
|
$this->addSql('ALTER TABLE customer DROP email');
|
|
}
|
|
}
|