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