migrations/Version20220209071349.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.  * Auto-generated Migration: Please modify to your needs!
  8.  */
  9. final class Version20220209071349 extends AbstractMigration
  10. {
  11.     public function getDescription(): string
  12.     {
  13.         return 'ON DELETE SET NULL to table hub_user on member_of_team_id, team on lead_id';
  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('ALTER TABLE hub_user DROP CONSTRAINT FK_8BD464F53F5737F6');
  19.         $this->addSql('ALTER TABLE hub_user ADD CONSTRAINT FK_8BD464F53F5737F6 FOREIGN KEY (member_of_team_id) REFERENCES team (id) ON DELETE SET NULL NOT DEFERRABLE INITIALLY IMMEDIATE');
  20.         $this->addSql('ALTER TABLE team DROP CONSTRAINT FK_C4E0A61F55458D');
  21.         $this->addSql('ALTER TABLE team ALTER lead_id DROP NOT NULL');
  22.         $this->addSql('ALTER TABLE team ADD CONSTRAINT FK_C4E0A61F55458D FOREIGN KEY (lead_id) REFERENCES hub_user (id) ON DELETE SET NULL NOT DEFERRABLE INITIALLY IMMEDIATE');
  23.     }
  24.     public function down(Schema $schema): void
  25.     {
  26.         // this down() migration is auto-generated, please modify it to your needs
  27.         $this->addSql('ALTER TABLE hub_user DROP CONSTRAINT fk_8bd464f53f5737f6');
  28.         $this->addSql('ALTER TABLE hub_user ADD CONSTRAINT fk_8bd464f53f5737f6 FOREIGN KEY (member_of_team_id) REFERENCES team (id) NOT DEFERRABLE INITIALLY IMMEDIATE');
  29.         $this->addSql('ALTER TABLE team DROP CONSTRAINT fk_c4e0a61f55458d');
  30.         $this->addSql('ALTER TABLE team ALTER lead_id SET NOT NULL');
  31.         $this->addSql('ALTER TABLE team ADD CONSTRAINT fk_c4e0a61f55458d FOREIGN KEY (lead_id) REFERENCES hub_user (id) NOT DEFERRABLE INITIALLY IMMEDIATE');
  32.     }
  33. }