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