<?php
declare(strict_types=1);
namespace DoctrineMigrations;
use Doctrine\DBAL\Schema\Schema;
use Doctrine\Migrations\AbstractMigration;
/**
* Team-lead: новая сущность, новая функциональность.
*/
final class Version20210513130218 extends AbstractMigration
{
public function getDescription(): string
{
return 'add table team';
}
public function up(Schema $schema): void
{
// this up() migration is auto-generated, please modify it to your needs
$this->addSql('CREATE TABLE team (id UUID NOT NULL, lead_id UUID NOT NULL, label VARCHAR(255) DEFAULT NULL, description TEXT DEFAULT NULL, PRIMARY KEY(id))');
$this->addSql('CREATE UNIQUE INDEX UNIQ_C4E0A61F55458D ON team (lead_id)');
$this->addSql('COMMENT ON COLUMN team.id IS \'(DC2Type:uuid)\'');
$this->addSql('COMMENT ON COLUMN team.lead_id IS \'(DC2Type:uuid)\'');
$this->addSql('ALTER TABLE team ADD CONSTRAINT FK_C4E0A61F55458D FOREIGN KEY (lead_id) REFERENCES hub_user (id) NOT DEFERRABLE INITIALLY IMMEDIATE');
$this->addSql('ALTER TABLE hub_user ADD member_of_team_id UUID DEFAULT NULL');
$this->addSql('COMMENT ON COLUMN hub_user.member_of_team_id IS \'(DC2Type:uuid)\'');
$this->addSql('ALTER TABLE hub_user ADD CONSTRAINT FK_8BD464F53F5737F6 FOREIGN KEY (member_of_team_id) REFERENCES team (id) NOT DEFERRABLE INITIALLY IMMEDIATE');
$this->addSql('CREATE INDEX IDX_8BD464F53F5737F6 ON hub_user (member_of_team_id)');
}
public function down(Schema $schema): void
{
// this down() migration is auto-generated, please modify it to your needs
$this->addSql('ALTER TABLE hub_user DROP CONSTRAINT FK_8BD464F53F5737F6');
$this->addSql('DROP TABLE team');
$this->addSql('DROP INDEX IDX_8BD464F53F5737F6');
$this->addSql('ALTER TABLE hub_user DROP member_of_team_id');
}
}