<?php
declare(strict_types=1);
namespace DoctrineMigrations;
use Doctrine\DBAL\Schema\Schema;
use Doctrine\DBAL\Types\Types;
use Doctrine\Migrations\AbstractMigration;
final class Version20230307133030 extends AbstractMigration
{
public function getDescription(): string
{
return 'Add additional_line field to the address table';
}
public function up(Schema $schema): void
{
$this->skipIf(
true === $schema->getTable('address')->hasColumn('additional_line'),
'The additional_line field already exists in the address table!'
);
$schema->getTable('address')
->addColumn('additional_line', Types::STRING, [
'length' => 255,
])
->setNotnull(false);
}
public function down(Schema $schema): void
{
$this->skipIf(
false === $schema->getTable('address')->hasColumn('additional_line'),
'The additional_line is already removed from the address table!'
);
$schema->getTable('address')
->dropColumn('additional_line');
}
}