<?php
declare(strict_types=1);
namespace DoctrineMigrations;
use Doctrine\DBAL\Schema\Schema;
use Doctrine\Migrations\AbstractMigration;
final class Version20260616120000 extends AbstractMigration
{
public function getDescription(): string
{
return 'Allow one customer and one staff account per email.';
}
public function up(Schema $schema): void
{
$this->addSql("ALTER TABLE user ADD account_type VARCHAR(20) DEFAULT 'staff' NOT NULL");
$this->addSql("UPDATE user SET account_type = 'customer' WHERE discr = 'customer'");
$this->addSql('DROP INDEX UNIQ_8D93D649E7927C74 ON user');
$this->addSql('CREATE UNIQUE INDEX UNIQ_USER_EMAIL_ACCOUNT_TYPE ON user (email, account_type)');
}
public function down(Schema $schema): void
{
$this->addSql('DROP INDEX UNIQ_USER_EMAIL_ACCOUNT_TYPE ON user');
$this->addSql('CREATE UNIQUE INDEX UNIQ_8D93D649E7927C74 ON user (email)');
$this->addSql('ALTER TABLE user DROP account_type');
}
}