<?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 Version20200319063744 extends AbstractMigration
{
public function getDescription(): string
{
return 'add field developer_id in table hub_user, set profile_id, developer_id, manager_id ON DELETE SET NULL';
}
public function up(Schema $schema): void
{
// this up() migration is auto-generated, please modify it to your needs
$this->abortIf($this->connection->getDatabasePlatform()->getName() !== 'postgresql', 'Migration can only be executed safely on \'postgresql\'.');
$this->addSql('ALTER TABLE hub_user DROP CONSTRAINT fk_8d93d649ccfa12b8');
$this->addSql('ALTER TABLE hub_user DROP CONSTRAINT FK_8BD464F5783E3463');
$this->addSql('ALTER TABLE hub_user ADD developer_id UUID DEFAULT NULL');
$this->addSql('COMMENT ON COLUMN hub_user.developer_id IS \'(DC2Type:uuid)\'');
$this->addSql('ALTER TABLE
hub_user
ADD
CONSTRAINT FK_8BD464F5CCFA12B8 FOREIGN KEY (profile_id) REFERENCES profile (id) ON DELETE
SET
NULL NOT DEFERRABLE INITIALLY IMMEDIATE');
$this->addSql('ALTER TABLE
hub_user
ADD
CONSTRAINT FK_8BD464F564DD9267 FOREIGN KEY (developer_id) REFERENCES developer (id) ON DELETE
SET
NULL NOT DEFERRABLE INITIALLY IMMEDIATE');
$this->addSql('ALTER TABLE
hub_user
ADD
CONSTRAINT FK_8BD464F5783E3463 FOREIGN KEY (manager_id) REFERENCES manager (id) ON DELETE
SET
NULL NOT DEFERRABLE INITIALLY IMMEDIATE');
$this->addSql('CREATE UNIQUE INDEX UNIQ_8BD464F564DD9267 ON hub_user (developer_id)');
}
public function down(Schema $schema): void
{
// this down() migration is auto-generated, please modify it to your needs
$this->abortIf($this->connection->getDatabasePlatform()->getName() !== 'postgresql', 'Migration can only be executed safely on \'postgresql\'.');
$this->addSql('ALTER TABLE hub_user DROP CONSTRAINT FK_8BD464F5CCFA12B8');
$this->addSql('ALTER TABLE hub_user DROP CONSTRAINT FK_8BD464F564DD9267');
$this->addSql('ALTER TABLE hub_user DROP CONSTRAINT fk_8bd464f5783e3463');
$this->addSql('DROP INDEX UNIQ_8BD464F564DD9267');
$this->addSql('ALTER TABLE hub_user DROP developer_id');
$this->addSql('ALTER TABLE
hub_user
ADD
CONSTRAINT fk_8d93d649ccfa12b8 FOREIGN KEY (profile_id) REFERENCES profile (id) NOT DEFERRABLE INITIALLY IMMEDIATE');
$this->addSql('ALTER TABLE
hub_user
ADD
CONSTRAINT fk_8bd464f5783e3463 FOREIGN KEY (manager_id) REFERENCES manager (id) NOT DEFERRABLE INITIALLY IMMEDIATE');
}
}