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