migrations/Version20200319063744.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 Version20200319063744 extends AbstractMigration
  10. {
  11.     public function getDescription(): string
  12.     {
  13.         return 'add field developer_id in table hub_user, set profile_id, developer_id, manager_id ON DELETE SET NULL';
  14.     }
  15.     public function up(Schema $schema): void
  16.     {
  17.         // this up() migration is auto-generated, please modify it to your needs
  18.         $this->abortIf($this->connection->getDatabasePlatform()->getName() !== 'postgresql''Migration can only be executed safely on \'postgresql\'.');
  19.         $this->addSql('ALTER TABLE hub_user DROP CONSTRAINT fk_8d93d649ccfa12b8');
  20.         $this->addSql('ALTER TABLE hub_user DROP CONSTRAINT FK_8BD464F5783E3463');
  21.         $this->addSql('ALTER TABLE hub_user ADD developer_id UUID DEFAULT NULL');
  22.         $this->addSql('COMMENT ON COLUMN hub_user.developer_id IS \'(DC2Type:uuid)\'');
  23.         $this->addSql('ALTER TABLE 
  24.           hub_user 
  25.         ADD 
  26.           CONSTRAINT FK_8BD464F5CCFA12B8 FOREIGN KEY (profile_id) REFERENCES profile (id) ON DELETE 
  27.         SET 
  28.           NULL NOT DEFERRABLE INITIALLY IMMEDIATE');
  29.         $this->addSql('ALTER TABLE 
  30.           hub_user 
  31.         ADD 
  32.           CONSTRAINT FK_8BD464F564DD9267 FOREIGN KEY (developer_id) REFERENCES developer (id) ON DELETE 
  33.         SET 
  34.           NULL NOT DEFERRABLE INITIALLY IMMEDIATE');
  35.         $this->addSql('ALTER TABLE 
  36.           hub_user 
  37.         ADD 
  38.           CONSTRAINT FK_8BD464F5783E3463 FOREIGN KEY (manager_id) REFERENCES manager (id) ON DELETE 
  39.         SET 
  40.           NULL NOT DEFERRABLE INITIALLY IMMEDIATE');
  41.         $this->addSql('CREATE UNIQUE INDEX UNIQ_8BD464F564DD9267 ON hub_user (developer_id)');
  42.     }
  43.     public function down(Schema $schema): void
  44.     {
  45.         // this down() migration is auto-generated, please modify it to your needs
  46.         $this->abortIf($this->connection->getDatabasePlatform()->getName() !== 'postgresql''Migration can only be executed safely on \'postgresql\'.');
  47.         $this->addSql('ALTER TABLE hub_user DROP CONSTRAINT FK_8BD464F5CCFA12B8');
  48.         $this->addSql('ALTER TABLE hub_user DROP CONSTRAINT FK_8BD464F564DD9267');
  49.         $this->addSql('ALTER TABLE hub_user DROP CONSTRAINT fk_8bd464f5783e3463');
  50.         $this->addSql('DROP INDEX UNIQ_8BD464F564DD9267');
  51.         $this->addSql('ALTER TABLE hub_user DROP developer_id');
  52.         $this->addSql('ALTER TABLE 
  53.           hub_user 
  54.         ADD 
  55.           CONSTRAINT fk_8d93d649ccfa12b8 FOREIGN KEY (profile_id) REFERENCES profile (id) NOT DEFERRABLE INITIALLY IMMEDIATE');
  56.         $this->addSql('ALTER TABLE 
  57.           hub_user 
  58.         ADD 
  59.           CONSTRAINT fk_8bd464f5783e3463 FOREIGN KEY (manager_id) REFERENCES manager (id) NOT DEFERRABLE INITIALLY IMMEDIATE');
  60.     }
  61. }