<?php
declare(strict_types=1);
namespace DoctrineMigrations;
use Doctrine\DBAL\Schema\Schema;
use Doctrine\Migrations\AbstractMigration;
final class Version20230524145059 extends AbstractMigration
{
public function getDescription(): string
{
return 'Add unique index to email column in company_user and health_mutual_user tables';
}
public function up(Schema $schema): void
{
$this->skipIf($schema->getTable('company_user')->hasIndex('UNIQ_CEFECCA7E7927C74'), 'Skipping index creation: company_user');
$schema->getTable('company_user')->addUniqueIndex(['email'], 'UNIQ_CEFECCA7E7927C74');
$schema->getTable('health_mutual_user')->addUniqueIndex(['email'], 'UNIQ_EF485363E7927C74');
}
public function down(Schema $schema): void
{
$this->skipIf(!$schema->getTable('company_user')->hasIndex('UNIQ_CEFECCA7E7927C74'), 'Skipping index removal: company_user');
$schema->getTable('company_user')->dropIndex('UNIQ_CEFECCA7E7927C74');
$schema->getTable('health_mutual_user')->dropIndex('UNIQ_EF485363E7927C74');
}
}