<?php
declare(strict_types=1);
namespace DoctrineMigrations;
use Doctrine\DBAL\Schema\Schema;
use Doctrine\DBAL\Types\Types;
use Doctrine\Migrations\AbstractMigration;
final class Version20220930122048 extends AbstractMigration
{
public function getDescription(): string
{
return '';
}
public function up(Schema $schema): void
{
$this->skipIf(
true === $schema->getTable('message')->hasColumn('document_name')
||
true === $schema->getTable('message')->hasColumn('document_url'),
'The document_name and document_url fields are already in the message table!'
);
$schema
->getTable('message')
->addColumn(
'document_name',
Types::STRING
)
->setNotnull(false)
->setDefault(null)
;
$schema
->getTable('message')
->addColumn(
'document_url',
Types::TEXT
)
->setNotnull(false)
->setDefault(null)
;
}
public function down(Schema $schema): void
{
$this->skipIf(
false === $schema->getTable('message')->hasColumn('document_name')
||
false === $schema->getTable('message')->hasColumn('document_url'),
'The document_name and document_url fields are already removed from the message table!'
);
$schema->getTable('message')->dropColumn('document_name');
$schema->getTable('message')->dropColumn('document_url');
}
}