<?php
declare(strict_types=1);
namespace DoctrineMigrations;
use Doctrine\DBAL\Schema\Schema;
use Doctrine\Migrations\AbstractMigration;
final class Version20230127143058 extends AbstractMigration
{
public function getDescription(): string
{
return 'Make messages_information not null';
}
public function preUp(Schema $schema): void
{
$this->connection->executeQuery(
"UPDATE message SET messages_information='[]' WHERE messages_information IS NULL"
);
}
public function up(Schema $schema): void
{
$this->skipIf(
true === $schema->getTable('message')->getColumn('messages_information')->getNotnull(),
'The messages_information field already not nullable in the message table!'
);
$schema->getTable('message')
->getColumn('messages_information')
->setNotnull(true);
}
public function down(Schema $schema): void
{
$this->skipIf(
false === $schema->getTable('message')->getColumn('messages_information')->getNotnull(),
'The messages_information field already nullable in the message table!'
);
$schema->getTable('message')
->getColumn('messages_information')
->setNotnull(false);
}
}