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