migrations/Version20210513130218.php line 1

Open in your IDE?
  1. <?php
  2. declare(strict_types=1);
  3. namespace DoctrineMigrations;
  4. use Doctrine\DBAL\Schema\Schema;
  5. use Doctrine\Migrations\AbstractMigration;
  6. /**
  7.  * Team-lead: новая сущность, новая функциональность.
  8.  */
  9. final class Version20210513130218 extends AbstractMigration
  10. {
  11.     public function getDescription(): string
  12.     {
  13.         return 'add table team';
  14.     }
  15.     public function up(Schema $schema): void
  16.     {
  17.         // this up() migration is auto-generated, please modify it to your needs
  18.         $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))');
  19.         $this->addSql('CREATE UNIQUE INDEX UNIQ_C4E0A61F55458D ON team (lead_id)');
  20.         $this->addSql('COMMENT ON COLUMN team.id IS \'(DC2Type:uuid)\'');
  21.         $this->addSql('COMMENT ON COLUMN team.lead_id IS \'(DC2Type:uuid)\'');
  22.         $this->addSql('ALTER TABLE team ADD CONSTRAINT FK_C4E0A61F55458D FOREIGN KEY (lead_id) REFERENCES hub_user (id) NOT DEFERRABLE INITIALLY IMMEDIATE');
  23.         $this->addSql('ALTER TABLE hub_user ADD member_of_team_id UUID DEFAULT NULL');
  24.         $this->addSql('COMMENT ON COLUMN hub_user.member_of_team_id IS \'(DC2Type:uuid)\'');
  25.         $this->addSql('ALTER TABLE hub_user ADD CONSTRAINT FK_8BD464F53F5737F6 FOREIGN KEY (member_of_team_id) REFERENCES team (id) NOT DEFERRABLE INITIALLY IMMEDIATE');
  26.         $this->addSql('CREATE INDEX IDX_8BD464F53F5737F6 ON hub_user (member_of_team_id)');
  27.     }
  28.     public function down(Schema $schema): void
  29.     {
  30.         // this down() migration is auto-generated, please modify it to your needs
  31.         $this->addSql('ALTER TABLE hub_user DROP CONSTRAINT FK_8BD464F53F5737F6');
  32.         $this->addSql('DROP TABLE team');
  33.         $this->addSql('DROP INDEX IDX_8BD464F53F5737F6');
  34.         $this->addSql('ALTER TABLE hub_user DROP member_of_team_id');
  35.     }
  36. }