<?php
declare(strict_types=1);
namespace DoctrineMigrations;
use Doctrine\DBAL\Schema\Schema;
use Doctrine\Migrations\AbstractMigration;
/**
* Auto-generated Migration: Please modify to your needs!
*/
final class Version20220209071349 extends AbstractMigration
{
public function getDescription(): string
{
return 'ON DELETE SET NULL to table hub_user on member_of_team_id, team on lead_id';
}
public function up(Schema $schema): void
{
// this up() migration is auto-generated, please modify it to your needs
$this->addSql('ALTER TABLE hub_user DROP CONSTRAINT FK_8BD464F53F5737F6');
$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');
$this->addSql('ALTER TABLE team DROP CONSTRAINT FK_C4E0A61F55458D');
$this->addSql('ALTER TABLE team ALTER lead_id DROP NOT NULL');
$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');
}
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('ALTER TABLE hub_user ADD CONSTRAINT fk_8bd464f53f5737f6 FOREIGN KEY (member_of_team_id) REFERENCES team (id) NOT DEFERRABLE INITIALLY IMMEDIATE');
$this->addSql('ALTER TABLE team DROP CONSTRAINT fk_c4e0a61f55458d');
$this->addSql('ALTER TABLE team ALTER lead_id SET NOT NULL');
$this->addSql('ALTER TABLE team ADD CONSTRAINT fk_c4e0a61f55458d FOREIGN KEY (lead_id) REFERENCES hub_user (id) NOT DEFERRABLE INITIALLY IMMEDIATE');
}
}